我只需要一个代码示例,用于将公共(public)帖子从 Facebook 页面收集到 PHP 数组。
我已经创建了一个应用程序,所以我有应用程序 ID/API key 和应用程序 key 。
例如,假设我想从 Facebook 获取所有 stackoverflow 公开帖子。我发现 stackoverflow 的 facebook 页面 ID 是“11239244970”,但现在,我如何获得他们所有的公开帖子?
$appKey = '635000000000874';
$appSecret = '567xxxxxxxxxxxxxxxxxxxxxxxxxx3e6';
$fbPage = '11239244970';
$publicFeed = array();
最佳答案
您对 PAGE_ID/feed 执行 HTTP GET
HTTP GET https://graph.facebook.com/11239244970/feed?access_token=YOUR_ACCESS_TOKEN
https://developers.facebook.com/docs/reference/api/page/#feed
在 PHP 中它可以像
一样基本$data = file_get_contents("https://graph.facebook.com/573948779291487/feed?access_token=YOUR_ACCESS_TOKEN");
$data = json_decode($data, true);
或者您可以使用 PHP SDK。
$publicFeed = $facebook->api('/573948779291487/feed');
要仅获取页面自己的帖子而不是喜欢页面的粉丝,请使用 /posts
端点。
关于php - 将 Facebook 公共(public)帖子从页面获取到 php 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15603434/