[英]Javascript SDK not working in Facebook Canvas App IE7/8
我正在開發一個畫布應用程序,並使其能夠在除IE 7/8之外的所有瀏覽器中按要求工作,在IE 7/8中,如果用戶尚未登錄Facebook,則我無法使該應用程序自動重定向到Facebook登錄屏幕。
我懷疑IE無法通過getLoginStatus方法獲取用戶狀態,因此無法觸發javascript重定向,因此刪除該應用程序功能也無法正常工作。
我已經通過在線JS皮棉工具運行了代碼,整理了幾件事,然后再次嘗試,但是沒有運氣
如果我在Facebook之外(例如https://mydomain.com/directory)嘗試此操作,則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));
});
我將不勝感激任何幫助
很可能是舊的第三方Cookie問題的另一種體現。 搜索第三方Cookie / P3P策略,以找到可以使其起作用的解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.