Post images to Twitter using Twitter + OAuth

I use Twitter + OAuth in my application ... I am successfully posting a message or text. But I also need to send an image ... so PLZ directs me to this work.

+1
source share
2 answers

Here's what the HTTP POST for Twitter looks like using update_with_media.xml .

Your application should set the authorization header in a way that is specific to your application, given the token, the secret of the tokens, etc.

Platform-specific libraries exist that help generate the value of the authorization header. For example, in .NET there is an open source OAuth.Manager class for this.

 POST https://upload.twitter.com/1/statuses/update_with_media.xml HTTP/1.1 Authorization: OAuth oauth_callback="oob", oauth_consumer_key="FXJ0DIH50S7ZpXD5HXlalQ", oauth_nonce="7774328k", oauth_signature="pUYjRnccmrBYiO1j9cliETsw%2B5s%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1318300521", oauth_token="59152613-vrlZ2edX56PudQtBmpAWd3SPDt9cPyAhibO7ysl6W", oauth_version="1.0" Content-Type: multipart/form-data; boundary=======c49479438c600bf59345e====== Host: upload.twitter.com Content-Length: 7320 Connection: Keep-Alive --======c49479438c600bf59345e====== Content-Disposition: form-data; name="status" working on a Tweet tool that uses the OAuth Manager library. --======c49479438c600bf59345e====== Content-Disposition: file; name="media[]"; filename="ThisIsAPicture.png" Content-Type: image/png ...binary png data here... --======c49479438c600bf59345e======-- , oauth_consumer_key = "FXJ0DIH50S7ZpXD5HXlalQ", oauth_nonce = "7774328k", oauth_signature = "pUYjRnccmrBYiO1j9cliETsw% 2B5s% 3D", oauth_signature_method = "HMAC-SHA1", oauth_timestamp = " POST https://upload.twitter.com/1/statuses/update_with_media.xml HTTP/1.1 Authorization: OAuth oauth_callback="oob", oauth_consumer_key="FXJ0DIH50S7ZpXD5HXlalQ", oauth_nonce="7774328k", oauth_signature="pUYjRnccmrBYiO1j9cliETsw%2B5s%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1318300521", oauth_token="59152613-vrlZ2edX56PudQtBmpAWd3SPDt9cPyAhibO7ysl6W", oauth_version="1.0" Content-Type: multipart/form-data; boundary=======c49479438c600bf59345e====== Host: upload.twitter.com Content-Length: 7320 Connection: Keep-Alive --======c49479438c600bf59345e====== Content-Disposition: form-data; name="status" working on a Tweet tool that uses the OAuth Manager library. --======c49479438c600bf59345e====== Content-Disposition: file; name="media[]"; filename="ThisIsAPicture.png" Content-Type: image/png ...binary png data here... --======c49479438c600bf59345e======-- 
+1
source

Easy to use Share Kit http://getsharekit.com/

NSString * imagetitle = @ "Image Name";

SHKItem * item = [SHKItem image: UIImage title: imageTitle];

[SHKTwitter shareItem: item];

0
source

All Articles