J7mbo / twitter-api-php

The simplest PHP Wrapper for Twitter API v1.1 calls
MIT License
1.82k stars 802 forks source link

Can't upload #45

Closed ghost closed 10 years ago

ghost commented 10 years ago

Can you provide a working example?

J7mbo commented 10 years ago

Can you elaborate on what the issue is?

ghost commented 10 years ago
$settings = array(
    'oauth_access_token' => "MY_OAUTH_ACCESS_TOKEN",
    'oauth_access_token_secret' => "MY_OAUTH_ACCESS_TOKEN_SECRET",
    'consumer_key' => "MY_CONSUMER_KEY",
    'consumer_secret' => "MY_CONSUMER_SECRET"
);

$url = "https://api.twitter.com/1.1/statuses/update_with_media.json";
$postfields = array('status' => 'Some status',
                    'media'  => array(@ . '/location'));
$requestMethod = 'POST';

$twitter = new TwitterAPIExchange($settings);
$response =  $twitter->buildOauth($url, $requestMethod)
                 ->setPostfields($postfields)
                 ->performRequest();
var_dump(json_decode($response));

returns: {"errors":[{"code":189,"message":"Error creating status."}]}

I checked the headers, I haven't hit any limits.

The lib works just fine when I try to post a simple status.

ghost commented 10 years ago

I found out what the problem was:

$postfields = array('status' => 'Some status',
                    'media'  => file_get_contents(@ . '/location'));