Skip to content
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

Uploading Animated GIF #499

Closed
novakben opened this issue Oct 5, 2016 · 2 comments
Closed

Uploading Animated GIF #499

novakben opened this issue Oct 5, 2016 · 2 comments

Comments

@novakben
Copy link

novakben commented Oct 5, 2016

I'm trying to upload a locally saved animated gif with the example in the readme, but I get an error.
I can post statue without image fine. But this gets broken when trying to add the media. (media/upload).

PHP Fatal error:  Uncaught exception 'Abraham\TwitterOAuth\TwitterOAuthException' with message 'Operation timed out after 5074 milliseconds with 0 bytes received' in /Users/USERNAME/vendor/abraham/twitteroauth/src/TwitterOAuth.php:403
Stack trace:
#0 /Users/USERNAME/vendor/abraham/twitteroauth/src/TwitterOAuth.php(334): Abraham\TwitterOAuth\TwitterOAuth->request('https://upload....', 'POST', 'Authorization: ...', Array)
#1 /Users/USERNAME/vendor/abraham/twitteroauth/src/TwitterOAuth.php(305): Abraham\TwitterOAuth\TwitterOAuth->oAuthRequest('https://upload....', 'POST', Array)
#2 /Users/USERNAME/vendor/abraham/twitteroauth/src/TwitterOAuth.php(252): Abraham\TwitterOAuth\TwitterOAuth->http('POST', 'https://upload....', 'media/upload', Array)
#3 /Users/USERNAME/vendor/abraham/twitteroauth/src/TwitterOAuth.php(235): Abraham\TwitterOAuth\TwitterOAuth->uploadMediaNotChunked('media/upload', Array)
#4 /Users/USERNAME/uplaod.php(59): Abraham\TwitterOAuth\TwitterOAuth->upload('media/ in /Users/USERNAME/vendor/abraham/twitteroauth/src/TwitterOAuth.php on line 403

This is my source code:

//Upload GIF to twitter
$media1 = $connection->upload('media/upload', ['media' => 'gifs/upload.gif']);
print_r($media1);
@oussaki
Copy link

oussaki commented Jan 13, 2017

Check the media guide : https://dev.twitter.com/rest/media/uploading-media.html
it could be the size of your file or the Frames that your GIF file has , it should be less than 350 frames.

@abraham
Copy link
Owner

abraham commented Jan 13, 2017

Operation timed out after 5074 milliseconds

You can increase the timeouts TwitterOAuth uses with the following code:

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
$connection->setTimeouts(10, 15);

The first number is how long to allow for connecting to api.twitter.com, the second number is the total time to allow.

@abraham abraham closed this as completed Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants