问题
I know you can append limit and offset values to the graph.facebook.com/id/photos API call to paginate through photos. But large limits don't seem to work well, photos end up missing. I read here that limit=0 gives you all photos, but again photos will be missing. So what's the biggest limit you can use reliably? What's the proper way to efficiently retrieve ALL photos?
Is there documentation on the limits of limit?
回答1:
Here's my experience with the Facebook API...
If you set a limit, you won't get any more than that. However, a large limit will most certainly give you less than you requested despite more existing. All of Facebook seems to run on a principle of "good enough" when it comes to responding to API queries. If you ask for 5000 items and after 5-15 seconds the system is only able to retrieve 350, then that's likely all you'll retrieve. There also seems to be a limit on size of content. So, the limit completely relies on the type of content you're querying and it's not a fixed amount. It's possible to say limit=5
and only get 4 items (even when more exist).
limit=0
used to give as many responses as possible, but I'm not sure if it still works. You can also use since
/until
to be more specific about the items you want to retrieve. But regardless, there's no way to know if you've gotten all possible responses.
回答2:
I faced the same issue in our application. "me/photos" doesn't give complete data. One can understand the permission associated with photos but then also "me/photos" end up not returning even photos with "public" permission.
We were able to resolve this issue by taking following approach. Now our application returns all tagged photos except the ones having restrictive permission.
First we did find the list of IDs of photos in which user is tagged using FQL. This can be achieved as following.
FB.api({
"method": 'fql.query',
"query": 'select object_id from photo_tag where subject=me()'
}
,function(resp)
{
}
The above API will give the IDs of photos in which user is active. Now once the ID is available the details of photo can be fetched as following.
FB.api({
"method": 'fql.query',
"query": 'select object_id from photo_tag where subject=me()'
}
,function(resp)
{
var photoId = resp.object_id;
FB.api("/" + photoId, function(data){////DO THE PROCESSING/////////////});
}
The above process involve larger number of requests to Facebook, but till now this is the only way that we have found out to fetch all possible tagged photos.
来源:https://stackoverflow.com/questions/7683230/how-to-retrieve-all-facebook-photos-a-person-is-tagged-in