페이스 북의 로그인 도움말 가이드를 사용하여 사용자가 로그인했는지 확인하는 스크립트를 작성하려고합니다. this guide을 기반으로 다음을 작성했습니다.예기치 않은 토큰 오류
<div id="fb-root"></div>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : '303594953085775', // App ID
channelUrl : 'http://mysite.com/pages/account/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 init code here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
} else if (response.status === 'not_authorized') {
// not_authorized
login();
} else {
// not_logged_in
login();
}
});
};
};
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
testAPI();
} else {
// cancelled
}
});
}
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
// 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>
내가 정확히 무엇을 잘못했는지는 알지 못합니다. 나는 그것을 4 번 복사했고, 그것이 정확하게인데도 불구하고 여전히 오류가 발생했습니다. 페이스 북 사이트에 쓰여진 내용입니다. 나는 기본적인 통화와 물건 몇 가지 작업을 수행하는 방법을 알고 난 정말 복잡한 자바 스크립트의이 종류에 대해 아무것도 몰라
Uncaught SyntaxError: Unexpected token }
Uncaught SyntaxError: Unexpected token .
:
나는 두 가지 오류를 얻을 수 이것은 현재 내가 건물에서 벗어나고 싶어하는 것입니다.
왜 오류가 발생했는지 알 수 있습니까? 어딘가에 나는이 바보 같은 페이 스북 가이드를 거치지 않고 정확한 스크립트 전체를 잡고 응용 프로그램 ID와 도메인을 대체 할 수 있습니까?
잡히지 않습니까? SyntaxError 메시지에도 줄 번호와 문자 번호가 있습니까? 당신은 여분이있는 것처럼 보입니다}; 첫 번째 fbAsyncInit 함수 후 – TommyBs
'if-else' 절을 다음과 같이 바꿀 수 있다는 것을 알고 있습니다 :'if (response.status! == 'connected') login();' – ifaour
실제 앱 ID입니까? 공개 포럼에 게시하지 마십시오. –