php - Facebook Graph 搜索结果与 "Public Posts"结果不匹配?

标签 php facebook facebook-graph-api facebook-php-sdk facebook-authentication

使用 graph.facebook.com 获得的结果似乎与您从他们自己的搜索结果中获得的结果不匹配。

例如: https://graph.facebook.com/search?q=www.mightytrainer.com&type=post&limit=25

对比

https://www.facebook.com/search/results.php?q=www.mightytrainer.com&type=eposts&init=quick&tas=0.07711535459384322

乔·古德温 (Joe Goodwin) 或塔林·希根 (Taryn Higgan) 都与我没有共同的 friend 。它们显示在网络结果中,但不显示在图表中。

我是否遗漏了一些基本的东西?

最佳答案

尝试使用用户访问 token 进行相同的搜索,就用户隐私设置而言,结果应该相似。

https://graph.facebook.com/search?q=www.mightytrainer.com&type=post&limit=25&access_token=your_user_access_token

图形浏览器中的示例。

https://developers.facebook.com/tools/explorer?method=GET&path=search%3Fq%3Dwww.mightytrainer.com%26type%3Dpost

引用: https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/

php 示例:假设 php sdk 3.1.1。已安装,并且应用程序已设置。

    // init sdk, sample coming
    require './src/facebook.php';
    $facebook = new Facebook(array(
      'appId'  => 'Your App Id Here',
      'secret' => 'Your App Secret Here',
      'cookie' => true, // enable optional cookie support
      ));      
    try { $user = $facebook->getUser(); } catch (FacebookApiException $e) {  }
    // Get the current access token if user.
    if($user){ 
    $access_token = $facebook->getAccessToken(); 
    // in the case of ajax we need to set the access token or will get expired error.
    // Comment out api get token, uncomment session.
    // $access_token = $_SESSION['fb_YourAppIdHere_access_token']; 
    if($access_token){ $facebook->setAccessToken($access_token); }
    };
    // access token usage should be handled by api.
    $api_search = $facebook->api('/search?q=www.mightytrainer.com&type=post');
// print results array  
echo '<pre>';
print_r($api_search);
echo '</pre>';

JavaScript 示例:

// init sdk, sample coming

关于php - Facebook Graph 搜索结果与 "Public Posts"结果不匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13939897/

相关文章:

Facebook Like 按钮在 Firefox 中不显示

facebook - 有没有办法可靠地检索最大版本的 facebook 相册照片的尺寸?

facebook-graph-api - 如何在 facebook iOS SDK 3.1 中发布到 friend 的墙?

facebook - 如何使用自定义 Facebook 对话框,如本示例

facebook - 使用 Facebook API 邀请好友?

php - file_put_contents 写入哪里?

php - 最佳性能的平均查询数

php - 如何使用 google-analytics 和 php 跟踪下载页面?

javascript - 如何调用 FB.api

php - 如何在单个查询中查询 3 个表?