开发者

How to retrieve ALL Facebook photos a person is tagged in

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? 开发者_JAVA技巧 What's the proper way to efficiently retrieve ALL photos?

Is there documentation on the limits of limit?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜