Orbatrix
Orbatrix

Reputation: 66

Posting an image on Tumblr using OAuth

I'm trying to post an image on Tumblr using OAuth. I'm using Objective C, but a general solution would be very helpful as well.

I manage to post an image that is online (using the "source" parameter). However, I can't post an image from the client (using the "data" parameter), and some issues confuse me.

1) Should I use "multipart/form-data" or "application/x-www-form-urlencoded"? I've seen conflicting claims on this issue.

2) What should I put in my post body and what should I put in my basestring? According to the oAuth specifications, if I use "multipart/form-data" then I don't need to add the parameters that I add to the post body (like "type" and "caption") to the base string, but even when I succeeded posting with "source", it only worked if I added the parameters to the base string as well.

3) In what format should I add the image to the body? If I need to also add it to the base string, then in what format should I add it there?

Thanks!

Upvotes: 2

Views: 642

Answers (1)

eagle.dan.1349
eagle.dan.1349

Reputation: 631

The problem with Tumblr is "unusual" implementation of OAuth (OAuth issues). It's not likely to be possible with "old" OAuth (from code.google.com/p/oauth/). I myself ended up using one of these solutions: crossbreeding OAuth with ASIFormDataRequest, but it is not likely to work with multiple images, or integrating TumblrUploadr. Also, Tumblr is likely to work better with new OAuth library (from here) , but it will definitely conflict with ShareKit if you use it.

Concerning your questions:

  1. TumblrUploadr uses application/x-www-form-urlencoded so it is likely to be this one.
  2. With any of solutions above, you should just pass UIImageJPEGRepresentation of your image. TumblrUploadr has it's own URL-encoding and for ASIFormDataRequest, I'm not sure.
  3. URL-encoded binary data, as it is said in Tumblr API. I myself didn't investigate ASIFormDataRequest deeply, so I'm not sure if you need to add it to base string.

Upvotes: 0

Related Questions