我需要从Facebook检索特定帐户的墙贴,但我只对包含照片的帖子感兴趣。有没有办法将这样的过滤器添加到Facebook图形API查询?类似的东西:
https://graph.facebook.com/DigitasLBiNL?fields=feed&type=photo
facebook数据包含一个type
属性,它返回photo
,所以我认为这是可能的,但我没有运气通过facebook sdk文档或修修补补
我知道我可以自己进行过滤,但我希望能够保留facebook返回的paging
属性。
答案 0 :(得分:6)
边缘
/{user_id}/home
(https://developers.facebook.com/docs/graph-api/reference/v2.1/user/home#read)
/{user_id}/feed
(https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed#read)
应该(根据文档)能够采用filter
参数,包含来自stream_filter
FQL表(https://developers.facebook.com/docs/reference/fql/stream_filter/)的过滤键。
如果我运行FQL
select name, value, type, filter_key from stream_filter where uid=me()
我得到以下结果:
{
"data": [
{
"name": "News Feed",
"value": null,
"type": "newsfeed",
"filter_key": "nf"
},
{
"name": "Status Updates",
"value": 2915120374,
"type": "application",
"filter_key": "app_2915120374"
},
{
"name": "Photos",
"value": 2305272732,
"type": "application",
"filter_key": "app_2305272732"
},
{
"name": "Links",
"value": 2309869772,
"type": "application",
"filter_key": "app_2309869772"
},
{
"name": "Pages",
"value": null,
"type": "public_profiles",
"filter_key": "pp"
},
{
"name": "Video",
"value": 2392950137,
"type": "application",
"filter_key": "app_2392950137"
},
{
"name": "Notes",
"value": 2347471856,
"type": "application",
"filter_key": "app_2347471856"
},
{
"name": "Groups",
"value": 2361831622,
"type": "application",
"filter_key": "app_2361831622"
}
]
}
因此,如果我选择app_2305272732
作为照片的过滤键,我就能成功运行以下的图谱API请求:
/me/home?filter=app_2305272732&limit=3
这给了我来自我的新闻源的最近三张照片。
您希望对用户/页面订阅源执行此操作(根据https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed#read处的文档不支持过滤页面,所以我尝试了这个:
/me/feed?filter=app_2305272732&limit=3
不幸的是,至少对我而言,这并不仅仅会返回照片帖子。所以我认为这是Facebook Graph API中的一个错误。
答案 1 :(得分:1)