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!
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:
TumblrUploadr uses application/x-www-form-urlencoded so it
is likely to be this one.
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.
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.
Related
Our LinkedIn API calls started failing. Even the simplest /v1/prople/~ calls started erroring with This resource is no longer available under v1 APIs.
So we're trying to migrate stuff using the new /v2 way, but somehow it seems not to be working. For example (and after requesting a token with the new scopes), a simple request to /v2/me fails to return the fields we need (amongst others, headline and location). When asking explicitly for these fields, we're told that we don't have access to them - even tho the token was generated using the r_basicprofile r_liteprofile r_emailaddress scopes.
We've tried numerous combinations and variations of asking for certain fields, projections, formats, etc from the Microsoft docs - with no avail and we're wondering whether the /v2 API is actually something functional - is there anyone successful using it, and if so, how?
A sample CURL request with an obfuscated Bearer would be a good way for us to understand what we're doing wrong - but it seems that even the simplest requests verbatim from the docs just fail.
EDIT: After some research, it looks like Microsoft changed their versioned API behavior without being consistent in the docs. Some docs point to r_liteprofile and some others to r_basicprofile as the default way to go now without being "Linkedin Partners". We were previously requesting r_emailaddress too and the headline and location parts of the r_basicprofile bits were used in our code in many different places.
These were two problems:
Some of the fields are removed from v1 (headline, email, location etc),
Most of the fields requested are not available in v2 without special scopes, but these scopes are very poorly documented as being part of a "LinkedIn Partner" program our app has to be accepted in before we can now use them.
The basic answer to this question is that LinkedIn (Microsoft) made backward-incompatible changes to their API.
I find it strange that you can set nearly every property of a given post through Tumblr's API, however, I cannot seem to find how one would go about setting the content source of a post when posting through Tumblr's API.
Any thoughts? By the way, not the source of the quote post type, but rather the content source that you would if you used their GUI.
I am new to designing REST APIs. I have trying to create following APIs for online game play
GET domain/api/games // return all games
POST domain/api/games // create a new game on behalf of current user
Now my issue is that when I try to create game using POST, I want userId to be sent to the API. I am not sure how to do this. Also note that I have another get API to get details of individual game, something like
GET domain/api/games/{gameId}
so I cannot pass userId to POST like domain/api/games/{useID} as it will conflict will above API.
So how do I pass usedId to POST. Also I don't want to use query params. Any suggestions to design this would be great.
When you are making a POST to a service, the parameters you communicate are known as BODY params, they don't go on the query string.
Different technologies have different APIs for interacting with POST params, but the underlying theory is the same, and is described by the W3C HTTP standard
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
The specifics of how to use POST params vary depending on the language and technology you're using. For example, if you are using jquery, there are a couple different ways to do it, with with the $.post('url', data, callback) method or with the $.ajax(...) option.
http://api.jquery.com/jquery.post/
http://api.jquery.com/jquery.ajax/
When reading POST params on the server, you'll generally access them using some some sort of request object, that will store your parameters in memory for you to access. This is highly dependent of the language and framework you're using, but here are links to some common ones:
NodeJS/express: http://expressjs.com/4x/api.html#request
PHP: http://php.net/manual/en/reserved.variables.post.php
ASP.Net: http://msdn.microsoft.com/en-us/library/system.web.httprequest.params(v=vs.110).aspx
Java/Spring: https://spring.io/guides/gs/handling-form-submission/
It should be either part of the context (you can pass it through header) or part of the game object. I prefer the context option, the httpheader can contain some auth bearer token so that you can figure out the user on the backend through the token.
Graph API is not returning image("picture" attribute) for objects corresponding to community pages, which used to be returned earlier. For example this https://graph.facebook.com/178790412179919 does not have picture attribute whereas the corresponding page has an image.
Also the FQL query done on the "albums" connection for some objects does not have a "cover_pid" attribute for an album corresponding to type "profile", which again used to work earlier.
Does anybody know if anything has changed in Graph API corresponding to this in last couple of weeks (I am fairly confident it used to work earlier in the expected way). I looked through Facebook API release notes but could not find any changes corresponding to this. Please let me know if this not appropriate post for this forum.
https://developers.facebook.com/docs/reference/api/page/
picture is a connection, not an attribute. So ...
https://graph.facebook.com/178790412179919/picture
And as the docs say: Returns a HTTP 302 with the URL of the user's profile picture.
Kinda goofy? Yes, but it works exactly as the docs say it does. I suspect they implemented it this way so it could easily be used in an <IMG> tag.
UPDATE:
It still works via FQL. In your case:
https://api.facebook.com/method/fql.query?query=SELECT+page_id%2C+pic+FROM+page+WHERE+page_id+%3D+178790412179919&format=json
I can confirm that this PREVIOUSLY worked, but NO LONGER works. Facebook have removed the picture connection from Community Pages.
I suspect the reason is that most of these images are pulled from Wikipedia, and there was a licensing / attribution issue.
Unfortunately, Facebook is no longer a reliable source of images for entities (e.g. bands).
Is it possible to create a photo collection using the flickr API?
I haven't found any example code to achieve this, however you CAN do it on the flickr website, and i suppose flickr uses the API internally for their site?
Dennis
This may be too late to help but, I thought I'd post the solution here for posterity (as this post came up while i was google'ing for the answer before i discovered it).
The method is undocumented in the Flickr API but, it does seem to work (tested via the REST interface).
The method is: flickr.collections.create
Required parameters:
auth_token
api_sig
title (Example value: "My Awesome Title Here.")
Optional parameters:
api_key
auth_hash
cb
description (Example value: "My Awesome Description Here")
parent_id (Example Value: 0)
src (Example: "js")
I found the method by enabling Firebug's console while creating a collection in the Flickr web interface and examining the POST. I have no idea what auth_hash nor cb refer to but, I would assume that they are required while using the JavaScript interface as opposed to REST.
Anything that uses the JavaScript interface on Flickr can be reverse engineered by examining the POST that occurs immediately after you take the action in the web interface.
Official support for the "flickr.collections.*" portion of the Flickr API has indeed been delayed for some reason (since at least 4/2007). There is a discussion thread over on Flickr, with a bit more information (reverse engineering) on the undocumented API.
Yes, you can. But, first you need to specify so-called 'primary photo'.
This means that flickr doesn't allow you to create empty albums (collections). I don't know why they decided to restrict creation of empty collections but it's a fact.