看來使用graph.facebook.com獲得的結果與您從自己的搜索結果中獲得的結果不匹配。Facebook圖形搜索結果與「公共帖子」結果不符?
例如: https://graph.facebook.com/search?q=www.mightytrainer.com&type=post&limit=25
與
無論是喬·古德溫或泰倫Higgan有共同的朋友和我在一起。它們顯示在網絡結果中,但不顯示在圖表中。
我錯過了一些基本的東西嗎?
看來使用graph.facebook.com獲得的結果與您從自己的搜索結果中獲得的結果不匹配。Facebook圖形搜索結果與「公共帖子」結果不符?
例如: https://graph.facebook.com/search?q=www.mightytrainer.com&type=post&limit=25
與
無論是喬·古德溫或泰倫Higgan有共同的朋友和我在一起。它們顯示在網絡結果中,但不顯示在圖表中。
我錯過了一些基本的東西嗎?
嘗試使用用戶訪問令牌進行的相同搜索,結果應該與用戶隱私設置相似。
https://graph.facebook.com/search?q=www.mightytrainer.com&type=post&limit=25&access_token=your_user_access_token
圖形瀏覽器中的示例。
參考: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
怎麼能Facebook的圖形API知道哪些用戶是你嗎? 你必須提供任何有效的應用程序的訪問令牌!
只需添加access_token = $令牌,您將獲得您的帳戶中的搜索結果。
https://graph.facebook.com/search?q=www.mightytrainer.com&type=post&limit=25&access_token=$token
我希望它有幫助。如果有效,考慮接受我的答案。
謝謝肖恩 - 如何獲得用戶(例如我的)訪問令牌?我可以通過JS/PHP組合登錄,但是從查詢/返回的信息沒有關於用戶令牌的信息。 –
好問題,js和php sdk都處理access_token。我將在我的答案中編輯有關這兩種方法的一些信息。 –
非常有趣 - 謝謝! 如果我可能會問,訪問令牌是臨時的嗎?如果我設置它,我可以將它保存爲離線狀態,然後在5天后使用它? –