您正在尝试使用以下代码显示权限对话框:
$permission = $facebook->api(array('method' =>'users.hasAppPermission','ext_perm'=>'publish_stream','uid'=> $uid));
if($permission != '1')
{
echo "<script type='text/javascript'>
var dialog = {
method: 'permissions.request',
perms: 'publish_stream',
redirect_uri: 'http://apps.facebook.com/abcd/'
};
FB.ui(dialog,null);
</script>";
}
此代码工作正常,但问题是,当用户允许权限时,他不会重定向到redirect_uri位置(即我的画布页面),而是转到画布URL(这是我的服务器的URL)。如何解决这个问题帮帮我。
答案 0 :(得分:0)
您可以在页面中添加以下javascript代码:
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
window.location.href = '/whatever/here';
} else {
// The user has logged out, and the cookie has been cleared
}
});