New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Posting image with tweet #181
Comments
You have to upload the image first. The api gives you an ID wich you send as media with yout post. eg:
|
What is |
Oh, sorry |
Hey, I got the response with the media_id_string but whenever I can check with the twitter, I can't find the images. Can you please let me know about the issues? Thanks, |
HI , ex: $json = $this->api |
Code above was just a little copy paste out of a bigger project. Made a little modification with api-init. Haven't tested the changes, but give it a try. |
@BugHunter2k Not working. give me any other option |
Take a look at the tests, they're usually a great indicator of how to do things. Firstly, upload the image. Here's testMediaUpload(). Then, the following test creates a tweet with the id of the uploaded image. Give that a try, they work otherwise the tests would be failing for everyone. |
Thanks for reply. |
Finally I did. $file = file_get_contents(DIR . '/img/logo.png'); // Upload image to twitter $json = $twitter // Result is a json string $url = 'https://api.twitter.com/1.1/statuses/update.json'; if(strlen($postfields['status']) <= 140) |
Hi, this is an old one. I'm just going through and cleaning up issues, although if you still need help, please feel free to reopen a new issue. Thanks. |
I cant even remember what I did to fix it lol |
Hi all this what got me all you have to do is create the array and only use media_data => base64_encode(file_get_contents(...)); |
line 32 |
Did above code work? |
Maybe I am missing something but is there a way to post an image with a tweet with your code?
As an example code I am trying something like this
require_once('TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "xxx",
'oauth_access_token_secret' => "xxx",
'consumer_key' => "xxx",
'consumer_secret' => "xxx"
);
$url = "https://api.twitter.com/1.1/statuses/update.json";
$requestMethod = 'POST';
$twimage = 'image.jpg';
$postfields = array(
'media[]' => "@{$twimage}",
'status' => 'Testing Twitter app'
);
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->buildOauth($url, $requestMethod)
->setPostfields($postfields)
->performRequest();
print_r($response);
The text was updated successfully, but these errors were encountered: