-1

我使用jQuery庫對用戶進行認證,使用這個腳本:Facebook上的JavaScript SDK幫助1002

<div id="fb-root"></div> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 
<script> 
    // Initialize the library with the API key 
    FB.init({ apiKey: 'SECRET_KEY' }); 

    // Fetch the status on load 
    FB.getLoginStatus(handleSessionResponse); 

    dojo.connect(dojo.byId('login'), 'click', function() { 
     FB.login(handleSessionResponse); 
    }); 

    dojo.connect(dojo.byId('logout'), 'click', function() { 
     FB.logout(handleSessionResponse); 
    }); 

    dojo.connect(dojo.byId('disconnect'), 'click', function() { 
     FB.api({ method: 'Auth.revokeAuthorization' }, function(response) { 
      clearDisplay(); 
     }); 
    }); 

是表示

出現了一個錯誤,請重試。然後按OK按鈕。

當我點擊確定按鈕,它說:

對不起,出事了。 我們正在努力盡快解決問題。

+0

您的handleSessionResponse回調方法在哪裏定義? – christophmccann 2012-03-03 15:56:34

回答

0

documentation for the JavaScript SDK

你可以看到你的密鑰是不需要的,因爲JavaScript是供任何人閱讀。 Facebook的身份驗證使用您請求的域來驗證它實際上是您的應用程序。

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
     FB.init({ 
      appId  : 'YOUR_APP_ID', // App ID 
      channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File 
      status  : true, // check login status 
      cookie  : true, // enable cookies to allow the server to access the session 
      xfbml  : true // parse XFBML 
     }); 

     // Additional initialization code here 
    }; 

    // Load the SDK Asynchronously 
    (function(d){ 
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
     if (d.getElementById(id)) {return;} 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/en_US/all.js"; 
     ref.parentNode.insertBefore(js, ref); 
    }(document)); 
</script> 
+0

非常感謝您的先生 – 2012-03-06 15:32:02

1

這是錯誤的:

FB.init({ apiKey: 'SECRET_KEY' }); 

沒有密鑰,只需將應用程序ID。