sdiegolo78 Posted May 19, 2012 Share Posted May 19, 2012 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...what do you think? include_once ('connect.php'); connect_to_database(); $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); Quote Link to comment https://forums.phpfreaks.com/topic/262785-posting-arrays/ Share on other sites More sharing options...
PeoMachine Posted May 21, 2012 Share Posted May 21, 2012 The variable $userid has a value? From where it came? And why you set the values two times? $data2 = array("text"=>"$response" , "user_id"=> "$userid"); $data2["text"] = "$response"; $data2["user_id"] = "$userid"; You dont need to use the " too. Quote Link to comment https://forums.phpfreaks.com/topic/262785-posting-arrays/#findComment-1347334 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.