JavaScript SDKを使用して、Webサイト用のFacebook接続アプリを開発しました。IE 以外のすべてのブラウザで正常に動作します。
IE では、ユーザーが [ログイン] ボタンをクリックしたテスト API 関数が呼び出されないことがあります。ログイン ウィンドウがポップアップし、ユーザーがユーザー名とパスワードを入力すると、testAPI 関数が呼び出されます。ただし、関数呼び出しが機能しない場合があります。しかし、ブラウザを更新して再試行すると、うまくいくことがあります。
このタイプの問題に直面している人はいますか?以下は私のJavaScriptコードです:
window.fbAsyncInit = function() {
FB.init({
appId : '', // App ID
channelUrl : '//localhost/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
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
testAPI();
} else if (response.status === 'not_authorized') {
// not_authorized
login();
} else {
// not_logged_in
login();
}
});
// Additional init code here
};
function login() { //alert("test");
FB.login(function(response) {
if (response.authResponse) {
// connected
testAPI();
} else {
// cancelled
}
}, { scope: 'email' });
}
function testAPI() {
//document.write ("tet");
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
//document.write("sdfs");
//document.write(response.name);
var test = response.first_name; //alert(test);
console.log('Good to see you, ' + response.first_name + '.');
console.log('Good to see you, ' + response.last_name + '.');
console.log('Good to see you, ' + response.id + '.');
console.log('Good to see you, ' + response.email + '.');
// console.log(response);
});
}
// 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));