简体   繁体   English

Facebook Graph Api - 仅检索包含照片的Wall帖子

[英]Facebook Graph Api - Retrieve only Wall posts that contain a photo

I need to retrieve wall posts from Facebook for a given account, but I'm only interested in posts that contain a photo. 我需要从Facebook检索给定帐户的墙贴,但我只对包含照片的帖子感兴趣。 Is there a way to add such a filter to a Facebook graph api query? 有没有办法将这样的过滤器添加到Facebook图形API查询? Something like: 就像是:

https://graph.facebook.com/DigitasLBiNL?fields=feed&type=photo https://graph.facebook.com/DigitasLBiNL?fields=feed&type=photo

The facebook data contains a type property which comes back as photo , so I would think this would be possible, but I haven't had any luck going through the facebook sdk documentation or tinkering around. Facebook数据包含一个type属性作为photo返回,所以我认为这是可能的,但我没有任何运气通过Facebook sdk文档或修补。

I know I could do the filtering myself, but I'd prefer to be able to keep the paging property that facebook returns. 我知道我可以自己进行过滤,但我更愿意保留facebook返回的paging属性。

The edges 边缘

should (as per documentation) both be able to take a filter paramenter, containing filter keys from the stream_filter FQL table ( https://developers.facebook.com/docs/reference/fql/stream_filter/ ). 应该(根据文档)都能够采用filter参数,包含来自stream_filter FQL表的过滤键( https://developers.facebook.com/docs/reference/fql/stream_filter/ )。

If I run the FQL 如果我运行FQL

select name, value, type, filter_key from stream_filter where uid=me()

I get the following result: 我得到以下结果:

{
  "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"
    }
  ]
}

So, if I choose app_2305272732 as filter key for the photos, I am able to run the follwoing Graph API request successfully: 因此,如果我选择app_2305272732作为照片的筛选键,则可以成功运行以下图表API请求:

/me/home?filter=app_2305272732&limit=3

This gives me the three most recent photo posts from my newsfeed. 这给了我来自新闻提要的三个最新照片。

You want to do this for User/Page feeds (Pages are not supported for filtering according to the docs at https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed#read ), so I tried this: 您想对用户/页面供稿执行此操作(根据https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed#read上的文档,不支持对页面进行过滤) ,所以我试过这个:

/me/feed?filter=app_2305272732&limit=3

Unfortunately, this doesn't return only photo posts, at least for me. 不幸的是,这不仅返回照片帖子,至少对我而言。 So I think this is a bug in the Facebook Graph API. 所以我认为这是Facebook Graph API中的一个错误。

According to 根据

https://developers.facebook.com/docs/graph-api/reference/stream-filter/ https://developers.facebook.com/docs/graph-api/reference/stream-filter/

you can use the type filter with value photo 你可以使用带有值phototype过滤器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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