これを機能させることができず、オンラインで見つけたすべての解決策を試しました。誰かがそれを調べて、私が間違っていることを教えてください。
$(document).ready(function(){
window.fbAsyncInit = function() {
FB.init({
appId: 'xxxxxxx',
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
window.location.reload();
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
$("#fb_login_status_check").click(function(){
FB.getLoginStatus(function(response) {
console.log(response);
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
console.log('User logged in and autenticated');
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
console.log('User logged in, but not autorized');
} else {
// the user isn't logged in to Facebook.
console.log('User not logged in');
}
}, true);
})
$("#fb_logout_button").click(function() {
if(FB.logout(function(response) {
console.log('User logout.');
})){
console.log('User logout.');
}else{
console.log('User didnt logout.');
}
});
$("#fb_login_button").click(function() {
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}else{
console.log('User cancelled login or did not fully authorize.');
}
},
{
scope: 'email,user_likes'
});
});
});
関数が呼び出された後に得られる応答は
authResponse null
status "unknown"
ユーザーがログインしていて、php sdk を使用してすべての情報を取得できます。助けてください、私は過去2日間これを機能させようとしています...