Facebook API获得更高的图像分辨率

时间:2014-07-31 16:42:20

标签: python facebook image facebook-graph-api

我目前使用Python facebook-sdk轮询facebook API以获取页面上的帖子列表。

非常粗略地看起来像

的基本部分
import facebook

# Get access token for my app_id and secret key
ACCESS_TOKEN = facebook.get_app_access_token(app_id, app_secret_key)

graph = facebook.GraphAPI(ACCESS_TOKEN)
profile = graph.get_object(USER)  # where USER is user's page I want posts for

# grab the posts
posts = graph.get_connections(profile['id'], 'feed')

这种方法效果很好,但如果帖子中有与之关联的图片,则返回到图片的链接通常是130x130图片,这对我来说太小了。举个例子:

 u'picture': u'https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/p130x130/10525675_431059123701393_2400070961435082030_n.png?oh=9a7391960a0b56341f1c927e34cd3517&oe=5436133D&__gda__=1415044571_40f45eb7ec13237c7732f99b4c284841'

我是否可以通过某种方式轮询API获取更高分辨率的版本,或将此网址转换为更高分辨率版本的网址?

(有些说明:我试过更换p130xp130 - > p430x430,它有时会起作用,但并非总是如此。)

1 个答案:

答案 0 :(得分:0)

我认为我实际上已经解决了这个问题,但如果有人知道更好的方式,我会有兴趣听到它。

我基本上做了:

# poll each post for actual source image if post is timeline photo
for post in posts:
    if post['type'] == u'photo':
        objid = post['object_id']
        picture = graph.get_object(objid)
        source = picture['source']
        # append source link to post
        post['source'] = source

我现在可以在我的其余脚本中使用此全分辨率原始URL链接。

相关问题