Retrieving Facebook Page Statuses with PHP

时间:2016-04-07 10:45:07

标签: php facebook facebook-graph-api

Having trawled the web for days, I cannot find an up-to-date, working method to retrieve a list of the latest statuses on a Facebook page.

  • On the status section of the Graph API, I am greeted with "This document refers to a feature that was removed after Graph API v2.3"
  • I can't get file_get_contents to work on Facebook pages as I'm presented with a Captcha

It's for competitor research, I only actually want:

  • Post date
  • Number of Likes/Share/Replies

I couldn't care less for the status content itself, just the metrics around it.

A JSON object would be great, but I'll take anything at this stage.

Anyone else managed to get this sort of data or know a way to use file_get_contents on Facebook pages?

Thanks.

1 个答案:

答案 0 :(得分:1)

状态只是某种类型的帖子 - 所以您需要做的只是请求页面的提要(分别是帖子),然后检查他们的类型是否为状态。

  

我刚刚尝试访问post对象以获取喜欢/喜欢的计数.etc并获取“[message] =>(#12)单数状态API已弃用v2.4及更高版本”

当您从/ feed或/ posts端点获取时,您需要使用“完整”帖子ID - page-id,下划线,post-id的组合。 (至少那是当前的格式,但Facebook的某个人告诉我,我们不应该依赖它,它可能会在某些时候改变。如果你真的只使用完整的id,那么最好,因为端点会返回它。)

既然你只对喜欢的总数感兴趣,而不是个人喜欢,你可以提出这样的请求,

$root

请求摘要(包含总计数),并限制返回零的个别喜欢的数量(以便不要求任何不必要的数据。)它对于评论的作用相同。但我认为对于共享帖子没有这样的计数,你只会得到一个帖子列表(可能不是全部,但只有你可以看到的那些。)