Facebook javascript sdk基本登录或初始化错误
我有以下代码主要是从复制粘贴 到 或 这带来了额外的警告 无效的应用程序Id:必须是表示应用程序Id的数字或数字字符串 已调用FB.init-这可能表明存在问题 和之前的错误相同: 未捕获错误:在sdk.js:96处指定的版本无效Facebook javascript sdk基本登录或初始化错误,javascript,facebook,logging,initialization,Javascript,Facebook,Logging,Initialization,我有以下代码主要是从复制粘贴 到 或 这带来了额外的警告 无效的应用程序Id:必须是表示应用程序Id的数字或数字字符串 已调用FB.init-这可能表明存在问题 和之前的错误相同: 未捕获错误:在sdk.js:96处指定的版本无效 这段代码有什么问题,以及如何简单地初始化或登录facebook。请让我知道 您是否尝试在init函数中指定版本 window.fbAsyninit=function(){ FB.init({ appId:'您的应用程序id', xfbml:是的, 版本:“v2.1”
这段代码有什么问题,以及如何简单地初始化或登录facebook。请让我知道 您是否尝试在init函数中指定版本
window.fbAsyninit=function(){
FB.init({
appId:'您的应用程序id',
xfbml:是的,
版本:“v2.1”
});
};代码>此更改后,我收到以下消息:应用程序配置不允许给定URL:一个或多个ping?client_id=797565713614652&domain=&origin=1&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2F…:应用程序设置不允许给定URL。它必须与网站URL或画布URL匹配,或者域必须是应用程序域之一的子域。并不是说我在dev.facebook中配置了有效的OAuth重定向URI。我不知道这个重定向uri是从哪里来的。我一直在学习这个教程。但没有这样的事。它必须指向我自己的应用程序id。如果出于安全原因为给定的应用程序id注册了重定向域,则应该有任何来自tutorialFacebook检查的内容。您可以在此处配置允许的域:
<body>
<div id="fb-root"></div>
<button id="fb-auth">Login</button>
<script type="text/javascript">
var button;
var userInfo;
window.fbAsyncInit = function() {
FB.init({ appId: '864702126886557', // your appId
status: true,
cookie: true,
xfbml: true,
oauth: true});
showLoader(true);
function updateButton(response) {
button = document.getElementById('fb-auth');
userInfo = document.getElementById('user-info');
if (response.authResponse) {
//user is already logged in and connected
FB.api('/me', function(info) {
login(response, info);
});
button.onclick = function() {
FB.logout(function(response) {
logout(response);
});
};
} else {
//user is not connected to your app or logged out
button.innerHTML = 'Login';
button.onclick = function() {
showLoader(true);
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(info) {
login(response, info);
});
} else {
//user cancelled login or did not grant authorization
showLoader(false);
}
}, {scope:'email,user_birthday,status_update,publish_stream,user_about_me'});
}
}
}
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
document.getElementById('fb-root').appendChild(js);
}(document, 'script', 'facebook-jssdk'));
</script>
js.src = "http://connect.facebook.net/en_US/sdk.js";
js.src = "http://connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.1";
js.src = "http://connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.0";