这是trying to use use facebook-php-sdk library to retrive facebook posts的后续文章
我正在尝试拉我所有的facebook帖子,以便我可以在我的网站上显示它们。这是我的代码:
$facebook = new Facebook(array(
'appId' => 'APPID',
'secret' => 'APPSECRET',
));
$pageId = 'MYID';
//$pageProfile = $facebook->api($pageId);
$pageFeed = $facebook->api($pageId . '/feed');
// Get User ID
$user = $facebook->getUser();
dpm($pageFeed);
drupal_goto($loginUrl);当我检查结果数组时,我只看到一个元素,而且它是我的facebook页面上的一个like。它会忽略所有的帖子和赞,甚至是我在调用loginUrl之后创建的帖子和赞。为什么会这样呢?
发布于 2013-08-31 00:40:01
为了获得提要,您必须使用令牌。要检索该令牌,请使用此url https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET对进行cURL调用
假设您已经获得了它,并将其命名为$token。使用它来获取您的提要。
$pageFeed = someCURLfunction("https://graph.facebook.com/{$yourid}/feed?{$token}");
// this is what you had $pageFeed = $facebook->api($pageId . '/feed');
$jsonStuff = json_decode($pageFeed); //it's a json object. You need to decode it
foreach ($jsonStuff as $feed)
{
//loop through it and
// finish it here
}这对我很有效。我希望它能帮上忙。
https://stackoverflow.com/questions/18536568
复制相似问题