2012-04-24 29 views
0

ATM IM試圖讓Facebook的API來工作,我被困在OAuth的的Facebook的Javascript OAuth錯誤Occurrred

<!DOCTYPE html> 
<head> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 
</head> 
<body> 
<fb:login-button autologoutlink="true" onlogin="OnRequestPermission();"> 
</fb:login-button> 
<script language="javascript" type="text/javascript"> 
    FB.init({ 
     appId: '143655195699763', 
     status: true, 
     cookie: true, 
     xfbml: true 
    }); 
</script> 
</body> 
</html> 

至於我嘗試登錄我得到一個錯誤

錯誤發生。請稍後再試。

任何想法?

另外,如果我使用那個,我仍然會得到相同的錯誤信息...也許它有我的appID待辦事項?

<!DOCTYPE html> 
<head> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 
</head> 
<body> 
<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '395527397147712', // App ID 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 
    }; 
</script> 
<script> 
function fb_publish() { 
    FB.ui(
     { 
     method: 'stream.publish', 
     message: 'Message here.', 
     attachment: { 
      name: 'Name here', 
      caption: 'Caption here.', 
      description: (
      'description here' 
      ), 
      href: 'url here' 
     }, 
     action_links: [ 
      { text: 'Code', href: 'action url here' } 
     ], 
     user_prompt_message: 'Personal message here' 
     }, 
     function(response) { 
     if (response && response.post_id) { 
      alert('Post was published.'); 
     } else { 
      alert('Post was not published.'); 
     } 
     } 
    ); 
    } 

</script> 

<input name="" type="button" onClick="fb_publish()"> 

</body> 
</html> 
+0

那是你唯一的代碼?你有沒有試過[this](https://developers.facebook.com/docs/reference/javascript/)? – 2012-04-24 06:56:22

+0

用新代碼更新了第一篇文章 – 2012-04-24 07:17:44

+0

您是否在瀏覽器的控制檯中看到任何東西? FB可能會寫更多關於錯誤的信息。 – Marc 2012-04-24 07:21:47

回答

0

我不知道這是否是原因,但在SDK文檔的例子有兩個功能,一個是fb.init(有的話),另一種是匿名函數調用本身加載你直接連接到DOM的腳本,也許你應該通過匿名函數加載腳本;驗證碼:

<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> 

阿洛斯,確保正確隱藏#fb-root元素,因爲在IE的SDK可能會引發問題。 More info here