I am currently trying to build an application to post videos to Twitter on behalf of a user.
So I currently have the application-key
, application-secret
, access-token
and access-secret
.
final TwitterTemplate twitterTemplate = new TwitterTemplate(
"application-key",
"application-secret",
"access-token",
"access-secret");
So using this I can actually post a tweet containing only text. If I want to include an image I have to include the workaround "solution" posted on a bug of spring-social-twitter. This resolves the image but the video still cannot be uploaded.
So the rational thinking was to try out this upload with postman to "isolate" the call itself.
In the previous image we can see the Authorization process. This is the same for Every single call I make.
with this Auth a simple POST
to https://api.twitter.com/1.1/statuses/update.json?status=hello
works. Same with 2 calls for image.
POST
tohttps://upload.twitter.com/1.1/media/upload.json?media_category=tweet_image
for the image upload ( body -> media : image ).POST
tohttps://api.twitter.com/1.1/statuses/update.json
merge the media_id with a new tweet.
But back to the video following again the official guide of twitter when I send this
the response is
when the request media_type does not contain /
then a valid response will return from tweeter with a media_id, lets call it X
.
So I append a video ( second command ) on X
and then finalize the video ( third command ) on X
. But as expected the response is
as the media_type was never provided. On the other hand if the video on the second step is pushed as base64 encoded ( and including the header for base64 encoding) then a response of
No matter what I have done so far I cannot make it post a video. I even used Postman as a proxy for twurl and captured the request of twurl that did upload the video. Changed the auth with mine ( because of nonce it requires to be recreated ) and the request failed to upload the video!
some notes :
- the credentials are up to dates and work from twurl.
- the video is valid and can be uploaded from both tweeter ui and twurl upload command.
- the base64 convert was encoded / decoded with linux base64 tool piped to file and validated that the size is the same.
If any other clarification is required please let me know!
Thank you in advance