如何在 Facebook Graph PHP SDK 中下载当前用户的所有照片?
How can I download all photos of the current user in the Facebook Graph PHP SDK?
我正在尝试使用 Facebook PHP SDK 查找当前用户被标记的所有照片。当我查询 $fb->get('/me/photos?type=tagged&limit=10000')
时,当我以我的身份登录时,列表中只有大约 500 张照片。如果我查看 Facebook 网页,它说有超过 3000 张我的照片。是否可以获取当前用户的所有照片?
是的,这是可能的,但不是一次调用即可。您必须使用分页,如
中所述
在这种情况下,JSON 响应中的 paging.next
属性 包含 link/call 以获得下一个结果。我建议将 limit
设置为最大值 50 或 100,
希望这个总结可以节省一些人的时间,因为我花了几天时间挠头。从 Graph API v2.5 开始,除非上传者已登录并授予 user_photos
权限,否则您的应用将无权查看其他人上传的照片。这甚至适用于标记了当前用户的照片。
为了让某个应用通过 Graph API 获取所有标记了您的照片,所有上传了标记您的照片的朋友都必须向该应用授予权限。
引用 Facebook 支持:
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.
我正在尝试使用 Facebook PHP SDK 查找当前用户被标记的所有照片。当我查询 $fb->get('/me/photos?type=tagged&limit=10000')
时,当我以我的身份登录时,列表中只有大约 500 张照片。如果我查看 Facebook 网页,它说有超过 3000 张我的照片。是否可以获取当前用户的所有照片?
是的,这是可能的,但不是一次调用即可。您必须使用分页,如
中所述在这种情况下,JSON 响应中的 paging.next
属性 包含 link/call 以获得下一个结果。我建议将 limit
设置为最大值 50 或 100,
希望这个总结可以节省一些人的时间,因为我花了几天时间挠头。从 Graph API v2.5 开始,除非上传者已登录并授予 user_photos
权限,否则您的应用将无权查看其他人上传的照片。这甚至适用于标记了当前用户的照片。
为了让某个应用通过 Graph API 获取所有标记了您的照片,所有上传了标记您的照片的朋友都必须向该应用授予权限。
引用 Facebook 支持:
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.