我正在使用Facebook图形API。
我想下载所有用户Facebook个人资料图片的全尺寸图片。
https://graph.facebook.com/<user alias>/picture
允许您访问用户当前配置文件图片的缩略图。
如果我想下载用户的全尺寸个人资料照片,看起来我需要在这个伪代码中做类似的事情。。。
# Get albums
albums = fetch_json('https://graph.facebook.com/<user alias>/albums')
# Get profile pictures album
profile_picture_album = albums['data']['Profile Pictures'] # Get profile picture album
# Get the pictures from that album
profile_pictures = fetch_json('https://graph.facebook.com/<profile_picture_album_id>/photos')
# Get the most recent (and therefore current) profile picture
current_profile_picture = profile_pictures['data'][0]
image = fetch_image_data(current_profile_picture['source'])
问题是,这需要两个不同的API访问,然后需要然后图像下载。如果相册中有很多相册或图片,我需要处理分页。
似乎应该有一种更快/更简单的方法来访问用户当前的个人资料图片。有人知道吗?
(仅供参考:我碰巧使用了Python来实现这一点,但我认为答案是语言不可知的)
我认为你不能一步到位,但你有几个选择:
1.
当您获得照片时,可以指定类型参数
large
(尽管您最多只能得到200px):http://graph.facebook.com/UID/picture?type=large
2.
您只需获取个人资料图片相册的封面照片—它始终是当前的个人资料图片:
https://graph.facebook.com/UID/albums?access_token=TOKEN
它将返回如下内容:
然后您可以访问:
https://graph.facebook.com/12345678912345123?access_token=TOKEN
并选择图像大小:
选择你的选择。
3.
由this blog提供:
我不相信引用,但我确实在处理测试样本时提出了基本相同的FQL查询。我在网上搜索时,这家伙把我揍了一顿。我想你将不得不在python中编辑它,如果你想在python中编辑它,那么我可以四处挖掘。
这将显示配置文件图像的原始全尺寸版本:
https://graph.facebook.com/someuser/picture?width=9999&height=9999
相关问题 更多 >
编程相关推荐