发生Facebook Javascript oAuth错误
atm我正试图让facebookapi正常工作,我在oauth上卡住了发生Facebook Javascript oAuth错误,javascript,facebook,api,Javascript,Facebook,Api,atm我正试图让facebookapi正常工作,我在oauth上卡住了 <!DOCTYPE html> <head> <script src="http://connect.facebook.net/en_US/all.js"></script> </head> <body> <fb:login-button autologoutlink="true" onlogin="OnRequestPermission();"&
<!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>
我不确定这是否是原因,但在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>
Alos,请确保正确隐藏fb根元素,因为在IE中SDK可能会导致问题 这是你唯一的密码?你读了吗?用新代码更新了第一篇文章你在浏览器的控制台中看到了什么吗?FB可能会在那里写入有关错误的更多信息。