简体   繁体   中英

How can I download all photos of the current user in the Facebook Graph PHP SDK?

I'm trying to find all photos where the current user is tagged in using the Facebook PHP SDK. When I query $fb->get('/me/photos?type=tagged&limit=10000') , only around 500 photos are present in the list when I'm logged in as me. If I check on the Facebook web page, it says there are over 3000 photos of me. Is it possible to get all photos of the current user?

Hopefully this summary saves some folks time since I spent a few days scratching my head over this. As of Graph API v2.5, your app will not have permission to view photos that other people have uploaded unless the uploader has logged into the app and granted the user_photos permission too. This even applies to photos the current user has been tagged in.

In order for an app to get all photos that you are tagged in through the Graph API, all of your friends who have uploaded photos that you are tagged in would have to grant permission to the app.

To quote Facebook support:

After checking, this should be the case. Each Facebook user is in control of what data is accessible to an application. If you have that user grant the user_photos (and possibly user_posts if it's the container for the photo) to the application, you should be able to fetch that photo.

Source: Facebook API Bug Report

Yes, it's possible, but not with just one call. You'll have to use pagination, as outlined in

In this case, the paging.next property in the JSON response contain the link/call to get the next results. I'd recommend to set the limit to 50 or 100 maximum,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM