Getting more than 25 photos from the Facebook Graph API - facebook

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.

Related

getting user likes in facebook

I am trying to get user likes in facebook. I can only get 100 at a time for some reason. i tried using the limit parameter in open graph syntax and it didn't help. I alwso tried writing an FQL query to get more likes and to no avail. No matter what I do, i get only 100 likes per request. It's even worse. Most of the likes are of no interest to me. I'm using only likes on several categories. if i could have gotten (using FQL) 100 likes of a user which are all of those categories, that would have been sufficient to me. But when I call the FQL query it seems that FB is querying on 100 first likes and returning the results instead of returning 100 results. I am despaired at this mechanism, is there a way out of this or is FB really gave no way to get more likes in a single call?
Read about paging in the docs: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2?locale=en_GB#paging
I guess the max limit is 100, if you want to get more than that you have to make another call by using paging. There is no way to filter with the API, you will have to do that on your own after getting the likes.

Facebook Graph / Fql: Get all pics

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).

what is the limit for the # of returned objects in graph.facebook.com/me/likes?

I need to get ALL user likes at once without pagination.
I could hit: graph.facebook.com/me/likes ...however, is there a limit to the # of objects returned by facebook? if so, what is that limit and can it be overwritten?
The default limit is something like 25 results. You can specify a limit by providing a limit parameter to facebook:
https://graph.facebook.com/me/likes?limit=100
Checkout the API Documentation under the heading "Paging".
That said, there's never a guarantee that you'll get all the likes at once, even if you set the limit parameter to be greater than or equal to the number of likes on an object.
On top of that, you'll often find that the number of likes reported on the Facebook website or by the Graph API is higher than what you can get by fetching the /likes connection in the Graph API. I'm trying (and failing) to find the SO question that talked about why that is, but if I remember right that number sometimes includes shares and other actions, not just likes.
You should use the pagination to page thru all the data that the Graph API can return.

facebook opengraph api return limitations?

I'm just experimenting with opengraph a bit and I was trying to retrieve all the posts a user has ever made. And I noticed that when do
user_id/statuses?limit=200
it only returns 99 statusses, is this because i'm doing it trough the graph api explorer on developers.facebook.com? is there a way to get all the users posts with the extra information, like in graph(comments/likes...)?
the next/previous links didn't help they both returned an empty json string
there are some limitations enforced here - if a user has (hypothetically) seven million posts, Facebook's servers will be bogged down with your request. All requests have a limitation on them - even if not specifically set. Pay attention to the parameters in the next and prev pagination links. They contain values such as :
limit - how many items will be returned in each request
offset - an offset to start from, an offset of 15 will start returning posts from the 15th and onward.
since - epoch timestamp defining the begining of a timeframe
untill- epoch timestamp defining the end of a timeframe
Hope this info helps...
There is also a limit in the amount of information that Facebook allows to be gotten via the Graph API. The data stores for the public Graph API are not the same as the data stores Facebook uses for the normal GUI. If your app desperately needs full information, it is possible that becoming a Facebook partner might get you better results.

How can I retrieve the full newsfeed of a user via the Facebook API?

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?