I’m trying to create a web application that will allow a user to post a tweet from a form directly on the webpage, instead of using Twitter’s own pre-built pop-up. The problem is, the snippet of code that I’m seeing around the web is not working:
$message = "Hello there! This is a tweet!";
$twitterObj->post('statuses/update', array('status' => "$message"));
And when I try to execute the code I get this error:
Warning: Invalid argument supplied for foreach() in /twitter/EpiOAuth.php on line 76
Warning: http_build_query() [function.http-build-query]: Parameter 1 expected to be Array or Object. Incorrect value given in /twitter/EpiOAuth.php on line 140
I’m building off the example and using the OAuth library found at this web address:
http://www.jaisenmathai.com/articles/twitter-php-sign-in.html
Does anyone have any tips?
EDIT
Problem solved! It turns out that this was the correct statement that I needed to use:
$twitterObj->post_statusesUpdate(array('status' => 'Message goes here.'));
This is what I use:
This is with the library found here: https://github.com/abraham/twitteroauth