我有一个从“页面”标签运行的应用。登录应用程序是通过Javascript完成的。
function facebooklogin() {
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
//user authorized
//SubmitLogin(response);
fbid = response.authResponse.userID; //valid response returned
token = response.authResponse.accessToken; //valid response returned
SubmitLogin();
}
else if (response.status === 'not_authorized') {
FB.login(function (response) {
if (response.authResponse) {
// user authorized
//SubmitLogin(response);
fbid = response.authResponse.userID; //valid response returned
token = response.authResponse.accessToken; //valid response returned
SubmitLogin();
} else {
// user cancelled
alert("User authorization is required for taking part in this promo.");
}
}, {
scope: 'user_about_me,user_birthday,user_checkins,user_hometown,user_location,publish_stream,email'
});
} else {
// the user isn't logged in to Facebook.
}
});
}
function SubmitLogin() {
//$("#token").val(response.authResponse.accessToken);
//$("#fbid").val(response.authResponse.userID);
//$("#login_form").submit();
$("#print_me").prop("href", "printable.php?fbid=" + fbid);
if (fbid != "") {
$.post("submit_user.php", "fbid=" + fbid + "&token=" + token, function(msg) {
var spl = msg.split("|");
if (spl.length == 3) {
//this part isn't an issue since the code never reaches it
post_wall();
$("#share_section").css({display: "none"});
$("#reward_section").css({display: "block"});
FB.Canvas.setSize();
$("#coupon_printout").html(spl[0]);
$("#qr_holder").html(spl[1]);
$("#expiration").html(spl[2]);
}
else {
//code always lands here because of the error in the php script
alert(msg);
}
});
}
else {
alert("You have not signed in to this app. If you did not see a sign in request, you may need to disable your pop-up blocker.");
}
}
当我回显返回值时,用户的FacebookID和访问令牌返回正确。然后我将这些传递给登录到应用程序的PHP脚本。到目前为止,一切正常。
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => /*my app ID*/,
'secret' => /*my app secret*/,
'cookie' => true
));
$signedRequest = $facebook->getSignedRequest(); //is blank
$user_id = $facebook->getUser(); //user's FacebookID gets returned
$user_profile = $facebook->api('/me','GET'); //OAuth error gets thrown
这是我的整个PHP代码,直到在Safari上抛出OAuth错误的部分。我已经尝试打印出我通过帖子传递的访问令牌,它出现了。但是,getAccessToken()打印出一个不同的值。
此区域内的其他浏览器未发生任何错误。
编辑: 将文件移动到另一台服务器,它开始为某些浏览器工作,而其他浏览器没有区别。