0

I have uploaded a image on twitter it is giving me response after hitting API but uploading status but not sharing images on wall,Don't know what's wrong with this code.

    // Turn off error reporting
    error_reporting(0);

    require_once('TwitterAPIExchange.php');

    /** Set access tokens here - see: https://dev.twitter.com/apps/ **/
    $settings = array(
    'oauth_access_token' => "XXXXXXXXXX",
    'oauth_access_token_secret' => "XXXXXXXXXXXXX",
    'consumer_key' => "XXXXXXXXX",
    'consumer_secret' => "XXXXXXXXXXX"
    );
    $url = "https://api.twitter.com/1.1/statuses/update.json";

    $requestMethod = 'POST';

    $twimage = '123.jpg';

    $postfields = array(
    'media_data' => base64_encode(file_get_contents($twimage)),
    'media[]' => "@{$twimage}",
    'status' => 'Testing Twitter status'
    );

    $twitter = new TwitterAPIExchange($settings);

    $response = $twitter->buildOauth($url, $requestMethod)
    ->setPostfields($postfields)
    ->performRequest();

    print_r($response);
  • 1
    Possible duplicate of [Post status + image with TwitterAPIExchange on Twitter](https://stackoverflow.com/questions/24550473/post-status-image-with-twitterapiexchange-on-twitter) – bato3 Feb 20 '18 at 19:21
  • No, i have upload random images,but this is not going to work. – Pooja Khandelwal Feb 21 '18 at 04:41

0 Answers0