私はキャンバス アプリを開発しており、ユーザーがまだ Facebook にログインしていない場合、アプリを Facebook ログイン画面に自動リダイレクトできない IE 7/8 を除くすべてのブラウザーで必要に応じて動作させました。
IE が getLoginStatus メソッドを介してユーザーの状態を取得していないため、javascript リダイレクトを起動できないと思われます。このため、アプリの削除機能も機能していません。
私はオンラインの JS lint ツールを使用してコードを実行し、いくつかのことを整理して再試行しましたが、うまくいきませんでした
https://mydomain.com/directoryなどの Facebook の外でこれを試すと、JS SDK は完全に機能し、Facebook のログイン ページにリダイレクトされますが、Facebook の iframe 内では同じことを行いません。
Facebook iframe 内でシステムがブラウザ モードを取得できず、これが関係するかどうか不明であることに気付きました
これが私の完全なコードです
$(document).ready( function() {
//Facebook JS SDK
window.fbAsyncInit = function () {
FB.init({
appId: 'xxxxxxxxxxxxxxxxx',
channelUrl: '//www.mydomain.co.uk/facebook-notes/channel.html',
// Channel File
cookie: true,
xfbml: true,
oauth: true,
status: true
});
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
//alert('hello');
$('a#remove-app').click(function () {
var request = response.authResponse.accessToken;
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
height: 140,
modal: true,
position: [236, 101],
buttons: {
"Yes": function () {
if (request) {
$.ajax({
url: 'https://graph.facebook.com/me/permissions',
type: 'GET',
data: 'method=delete&access_token=' + request,
dataType: 'jsonp',
success: function (response) {
top.location.href = 'http://facebook.com';
}
});
}
},
Cancel: function () {
$(this).dialog("close");
}
}
});
return false;
});
} else {
//alert('user not logged in');
var oauth_url = 'https://www.facebook.com/dialog/oauth/';
oauth_url += '?client_id=xxxxxxxxxxxxxxx';
oauth_url += '&redirect_uri=' + encodeURIComponent('https://apps.facebook.com/app_name/');
oauth_url += '&scope=email';
window.top.location = oauth_url;
}
},
true);
$('a#invite-a-friend').click(function () {
sendRequestViaMultiFriendSelector();
});
// Multi friend selector for Facebook
function sendRequestViaMultiFriendSelector() {
FB.ui({
method: 'apprequests',
message: 'Come and join the app on Facebook'
});
}
function requestCallback(response) {
alert (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));
});
助けていただければ幸いです