Posting arrays via twitter api

i am basically trying to retrieve the response of a chatbot from mysql database with query below. As i run script i don’t get any error from the server but it seems the post doesn’t take $data2 which is an array that includes the keys “user_id” and “text” that are normally accepted (eg: $dmessage->post(‘direct_messages/new/wrap_links=true’, ‘text’->‘example’, ‘12345’);

As result of the above i can’t post to Twitter the chatobot response as the recipient (my other twitter account) doesn’t get the answer…

include_once ('connect.php');


$query2 = mysql_query ("SELECT response FROM conversation_log WHERE id = (SELECT MAX(id) FROM conversation_log)") or die (mysql_error());

$row = mysql_fetch_row($query2);

$response = $row[0];

//this is the array with the parameters to be used to send bot responses via Twitter API. It normally takes
$data2 = array("text"=>"$response" , "user_id"=> "$userid");

//this modifies the array values with response e userid fields
$data2["text"] = "$response";
$data2["user_id"] = "$userid";

require_once('config_oauth.php'); // includes the applications Oauth keys

require_once($_SERVER['DOCUMENT_ROOT'].'Program-O/gui/xml/oauth/twitteroauth.php'); //Full path to twitteroauth.php library

$dmessage = new TwitterOAuth($consumer_key,$consumer_secret, $oAuthToken, $oAuthSecret); // create new instance with the credentials

//sends the bot response via Twitter API by going through the array $data2
$dmessage->post('direct_messages/new/wrap_links=true', $data2);

Are you following the people your trying to send the private messages to as unless you are it won’t work as you expect.