I'm having return issues with graph API and I'm wondering if any knows why or how I can fix it.
I need to download all photo data for a given user (friend data, not the active user). Here are the two things I have tried.
FQL: "select pid from photo where subject=friend_uid"
Graph: "friend_uid/photos?fields=picture,created_time,tags.fields(name,id)&limit=1000"
I have friends_photos and user_photos permissions.
Any users with > 1000 tags will have drastically reduced result numbers.
For example, it will only return around 200 photos or so which is not acceptable, I need all of them
Chunking with since/until (or created_time < or > __) as well as limit clauses only improves the result count with FQL but the amount of chunking makes it VERY inefficient.
Any ideas? The tag data is also important for my purposes.
So, I need the proper query or sequence of queries to obtain ALL tag data for all photos of a given user_id using either FQL or graph-api.
I recently created a similar project (pulls all the photos from all your facebook friends in order) in PHP. Facebook's limits are poorly documented but I found that with the Graph API, it's 400 photos the friend is tagged in and 5000 photos the friend uploaded per request. Note that pulling from {user}/photos only pulled photos they are tagged in, while {user}/photos/uploaded only pulls photos that {user} uploaded. I figured that that 400 tagged and 5000 uploaded photos was enough for my situation.
If you do need additional photos, you will have to check the number of returned photos for the user for the /photos request and check if it's equal to 400. If so, you will have to go on to the next page, recursively.
For the /photos/uploaded request, Facebook uses cursor-based pagination (see bottom of this page), which means that pagination->next and pagination->prev data is only sent when there are more values to return. This makes it fairly easy to get the next page (once again you will have to do this recursively).
Related
To get the latest photos of my friends (with Graph Api v.2.1, NO FQL) I use the following:
me/home/?fields=story,object_id,from,type&filter=app_2305272732&since=1407507775
This works, but only shows the photos that they have uploaded or updated.
How I can get the photo (my friend is tagged) but is not the owner of the picture?
I can see that kind of pictures with this query type:
me/friends/?fields=id,name,photos.limit(2){created_time,updated_time,from,id,name,tags}&date_format=U&limit=15&since=1407507775
But it's complicated. When there is a lot of information, the query is slow and does not return results. Lowering the limits and make multiple requests is not an acceptable solution.
When pulling photos from a Facebook album via the graph API, i.e.
https://graph.facebook.com/<albumid>/photos?access_token=<token>&limit=999&fields=name,source
For some albums, it only supplies partial results. For instance, an album with 15 photos may only return 13 photos. This call:
https://graph.facebook.com/<albumid>?access_token=<token>&fields=count
...Indeed returns the proper count of 15. My first thought was that perhaps these 2 "missing" photos have more limiting privacy settings, but every photo in the entire album (which is owned by the owner of the token, incidentally) has the same "visible to friends" privacy setting. Most albums do return all photos, as expected.
Any ideas as to what might be causing this behavior?
I was missing 4 photos of 33 for one of my albums. I added 'user_status' to the permissions and it suddenly works.
Instead of the cause of why it happens, I am suggesting you a workaround. Graph api is well known for returning partial results. (You can search for that, and you get hell lot of such issues.)
why not go the FQL way?
Checkout :https://developers.facebook.com/docs/reference/fql/photo/
You can get the id, or direct images links of the pictures in an album in a single query.
Sample : SELECT src_big FROM photo WHERE aid="20531316728_324257"
This returns the url of biggest version of the pictures inside the album.
This should probably solve your problem as long as you are using a user access_token and not app access_token.
Here's the problem I'm having -- I want to pull the latest 20 wall posts from a company's Facebook page using Graph API, but only those posts that were authored by that company. For instance, if I were pulling from the Grey Poupon Facebook page, I don't want any of the wall posts that their fans put up, just the ones that Grey Poupon put up.
From my vantage point, there's no way to do this, other than by pulling way too many, then cycling through each result and checking the "from" data to make sure it matches the page name till that limit hits 20. But that's awfully inefficient and still doesn't guarantee a result set of 20. Am I missing something, or is that my only option?
What exactly are you requesting from the API – /pageid/feed, or /pageid/posts …?
The latter should only contain the page’s own posts.
Also, you could use the FQL stream table to filter by actor_id.
I would like to retrieve the full newsfeed including historical data of a given user. In principal, this is straight forward using either an authenticated call to the Graph API or to the FQL API.
With the Graph API, I access the me/home endpoint. This results in 25 entries. I can iterate over the pages and retrieve around 8 pages back into history giving me around 200 entries. I write around 200 entries, because with each run through this I get a different number of total entries. Sometimes more, sometimes less.
With the FQL API, I call SELECT post_id, created_time, actor_id, message FROM stream WHERE filter_key = 'nf' AND is_hidden=0 AND created_time > 1262304000 LIMIT 500 where the created time reflects 1 Jan 2010. This gives me around 150 entries.
Both methods don't seem to allow to work your way backwards into history. In the FQL query, I also tried to play around with the created_time field and LIMIT to go backwards in small chunks but it didn't work.
The documentation of the stream table http://developers.facebook.com/docs/reference/fql/stream/ says somehow cryptically:
The profile view, unlike the homepage view, returns older data from our databases.
Homepage view - as far as I understand - is another word for Newsfeed, so that might mean that what I want is not even possible at all?
To make things worse (but that's not the main topic of this question) the returned datasets from the two methods differ. Both contain entries that the other does not show but they also have many entries in common. Even worse, the same is true in comparison to the real newsfeed on the Facebook website.
Does anyone have any experience or deeper insights on this?
Maybe I am mis-understanding your question, but can't you simply call the graph api with /me/home?limit=5000 and then ?limit=5000&offset=5000 or whatever the max limit value Facebook allows is?
I'm trying to retrieve all the photos a user is tagged in using the Graph API but I can only get the latest 25.
Is it possible to get more, and if so, how?
Have you tried adding a limit and offset parameters? Quoting the documentation:
Paging
When querying connections, there are several useful parameters that enable you to filter and page through connection data:
limit, offset: https://graph.facebook.com/me/likes?limit=3
until, since (a unix timestamp or any date accepted by strtotime): https://graph.facebook.com/search?until=yesterday&q=orange
Currently there is 100 items limitation per query both on photos and likes:
However, 100 pics query takes so much time to run for me.
The following API call:
https://graph.facebook.com/me/photos?limit=500
gives only 100 results with paging link.
Run in FQL explorer (If you have more than 100 pic on your account):
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fphotos%3Flimit%3D500
Setting limit=0 may not always work in the case that a user has a huge number of tagged photos. Also note that the tagged photos graph API can return a large number of embedded comments as well, so especially if you are developing a mobile app, it can take a long time to return all the photo data. Finally I find that sometimes Facebook will limit the number of entries it can return in times of high load.
So... perhaps the best way is to use the "paging" "next" url that appears at the end of the returned photo data. This gives you the next graphAPI call that you can then use to get the next x photos. It does this by using and pre-populating the limit and until parameters and incorporating them within the graph api call. Very handy.