问题
I am using Twitter+OAuth in my app ...i am successfully posting the message or text.But i have to post image also...so plz guide me to do this job.
回答1:
This is what an HTTP POST to Twitter looks like, using update_with_media.xml.
Your app must set the Authorization header in a way that is specific to your app, considering the token, token secret, and so on.
There are platform-specific libraries that help generate the value of the Authorization header. For example in .NET, there is an open-source OAuth.Manager class to accomplish that.
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======--
回答2:
Easy to use Share Kit http://getsharekit.com/
NSString *imageTitle = @"Image Title";
SHKItem *item = [SHKItem image:UIImage title:imageTitle];
[SHKTwitter shareItem:item];
来源:https://stackoverflow.com/questions/9616102/posting-image-to-twitter-using-twitteroauth