2011-09-14 128 views
6

我有一個用戶的電子郵件,並且我想使用javascript api在Facebook中搜索它們。使用JavaScript API執行Facebook搜索

我知道我需要的東西

FB.api('/search', {q: '[email protected]', type: 'user'}, function(response) { 
    //Handle response 
}); 

但是,這似乎並沒有工作,我甚至不得到迴應。

我也試過把它放在裏面和/或打電話給FB.login(),這只是由於某種原因失敗。

有什麼建議嗎?他們關於如何使用它的文檔非常模糊。

編輯:

這裏是所有的相應代碼:

<div id="fb-root"></div> 
<script type="text/javascript" > 
    FB.init({ 
     appId: 'apikey', //Actual API key removed for obvious reasons 
     status: true, // check login status 
     cookie: true, // enable cookies to allow the server to access the session 
     xfbml: true, // parse XFBML 
     oauth: true // enable OAuth 2.0 
    }); 
</script> 

<script type="text/javascript" > 
    FB.login(function (response) { 
     if (response.authResponse) { 
      FB.api('/search', {q: '[email protected]', type: 'user'}, function(response) { 
      { 
       alert(response); 
      }); 
     } 
     else { 
      alert(response.toString()); 
     } 
    }); 
</script> 
+0

您是否得到了這個工作? – aleXela

+0

@alexela從來沒有最終得到它的工作。 –

回答

0

你一起API密鑰傳遞?

我會從這裏開始:http://developers.facebook.com/docs/reference/javascript/

,然後按照這個例子中,使用0Auth 2.0形成的,你將需要如何讓你的API請求的基礎:https://developers.facebook.com/blog/post/525/(這篇文章似乎是最新的!)

+0

我使用我的應用程序ID來調用FB.init,這是你的意思嗎? –

+0

是的。有沒有更多的代碼可以添加到你的問題中?我想知道是否有什麼超出你的FB.api()調用,可能會阻止這一點。 – BumbleB2na

+0

爲問題添加了適用的源代碼,希望對您有幫助 –

3
var urlCall = "https://stackoverflow.com/search?q=Bamboo&type=page&access_token="; 
FB.api(urlCall, function(response) { 
    //you code to execute  
}); 

終於在挖了一些東西后發現這個。