Search code examples
phppoststweets

How to tweet message on logeed in user profile


I Have integrated tweeter connect with my website.I have used oauth code to post on tweeter. I have mentioned part of the code what I have used below.

$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
// Your Message
$message = "hi I am fine";
// Send tweet     
$tweet->post('statuses/update', array('status' => "$message"));

But I can not post on the user page who is logged in ,It only shows on application's user page, should I add anything with this code?if so please let me know what should I do with code.


Solution

  • This code is alright. It will work.

    But the main thing is to figure out what is the error and why it's not working. Simply replace

    $tweet->post('statuses/update', array('status' => "$message"));
    

    using:

    $mytweet=$tweet->post('statuses/update', array('status' => "$message"));
    var_dump($mytweet); 
    // print the output coming from the post request, that you done using twitterOauth
    

    I already have used the same code, first time it's not working as my Application was Read Only Type and now works properly! So, make sure your Application settings is Read and Write type at least. Here the solution in details: https://stackoverflow.com/questions/18035906/tweeting-with-php-not-working/18036339#18036339