In Facebook FB.ui (method: permissions.request) user is not redirect to proper location

3.2k views Asked by At

Hi i m trying to show permission dialog using following code:

$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>";
}

This code works fine but problem is that when user allow to permissions he is not redirected to redirect_uri location(that is my canvas page) instead it goes to canvas url (that is my server's url). how to solve this problem Help me.

1

There are 1 answers

1
Raisen On

You can add the following javascript code in your page:

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
    }
});