I upload photos to TwitPic using OAuth from a .NET application written in C #.
The oAuth stuff is a bit complicated. I found two bits of .NET code to process it, but was not satisfied. DotNetOpenAuth seemed pretty heavy, more than I needed. (I just want to make signatures and tokens). The OAuthBase.cs code seemed confusing and ridiculous to me. I had to pass 6 string parameters to the methods, and if I got any order, woe to me.
So, I wrote the code to do it myself, it is quite small and seems to work. It works to get "request tokens." It works to open the authorization web page and receive "access tokens." It also works for uploading photos to TwitPic.
All HTTP responses are returned as 200 or 201.
The download of the HTTP message is as follows:
POST http://api.twitpic.com/2/upload.json HTTP/1.1
Content-Type: multipart/form-data; boundary=48cb9a6d-1f1d-432d-b6e3-307e32e8228a
X-Auth-Service-Provider: https://api.twitter.com/1/account/verify_credentials.json
X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/",
oauth_consumer_key="Dv1er93yKzEMn74hZfPmJA",
oauth_nonce="51fi305k",
oauth_signature="4oWcmZcd%2F%2F81JslJ70xFXFm8%2BQs%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1292277715",
oauth_token="59152613-z8EP4GoYS1Mgo3E29JfIqBnyTRlruAJs8Bkvs3q0T",
oauth_version="1.0"
Host: api.twitpic.com
Content-Length: 14605
Expect: 100-continue
Connection: Keep-Alive
--48cb9a6d-1f1d-432d-b6e3-307e32e8228a
Content-Disposition: file; name="media"; filename="CropperCapture[10].jpg"
Content-Type: image/jpeg
....
--48cb9a6d-1f1d-432d-b6e3-307e32e8228a
Content-Disposition: form-data; name="key"
twitpic-api-key-here
--48cb9a6d-1f1d-432d-b6e3-307e32e8228a
Content-Disposition: form-data; name="message"
uploaded from Yappy. (at 12/13/2010 5:01:55 PM)
--48cb9a6d-1f1d-432d-b6e3-307e32e8228a--
json I get back from loading like this:
{"id":"3f0jeiw5",
"text":"uploaded from Yappy. (at 12\/13\/2010 5:01:55 PM)",
"url":"http:\\/twitpic.com\/3f0jeiw5",
"width":257,
"height":184,
"size":14156,
"type":"jpg",
"timestamp":"Mon, 13 Dec 2010 22:02:06 +0000",
"user":{
"id":54591561,"screen_name":"bfavre"}
}
But the problem is that after uploading the image to Twitpic, the image is available on TwitPic, but the linked message never appears on Twitter.
What gives?
, TwitPic + oAuth , HTTP, Twitter, ? , oAuth , - - , TwitPic .
?
. 2010 , X-Auth-Service-Provider of https://api.twitter.com/1/account/verify_credentials.json TwitPic "verify_credentials.json" on twitter.com, . , , .
, https://api.twitter.com/1/status/update.json Twitter TwitPic . - , Twitter.
HTTP-. ?
UPDATE
URL- https://api.twitter.com/1/status/update.json POST 401:
{"errors":
[{"code":401,
"message":"Could not authenticate you (header rejected by twitter)."}]
}
, , twitter dev. , , , , sig .