FB.login redirect_uri

时间:2013-01-09 03:50:37

标签: php javascript facebook facebook-graph-api facebook-javascript-sdk

我使用Fb.Login登录我的facebook应用程序中的用户。是否存在redirect_uri参数的可能性?在成功登录后,我想将用户重定向到:https://www.facebook.com/page/app_33229693355?app_data=code,在经典登录时我用户redirect_uri参数在登录后重定向,但是在这里?

FB.login(function(response) {
}, {scope: \'publish_stream, photo_upload, user_birthday\'});

我需要这个,因为下一步是用php写一张图片。

1 个答案:

答案 0 :(得分:0)

  FB.Event.subscribe('auth.login', function () {
      window.location = "http://example.com";
  });

当auth状态更改为已连接时,将触发重定向。查看此FB.Event.subscribe链接以获取更多信息。

如果您想要用户数据,

 FB.login(function(response) {
   if (response.authResponse) {
     console.log('Welcome!  Fetching your information.... ');
     FB.api('/me', function(response) {
         // make an ajax call to your php code and pass the name etc ...
         // on success of the ajax call, use window.location to redirect 
        console.log('Good to see you, ' + response.name + '.');
     });
   } else {
     console.log('User cancelled login or did not fully authorize.');
   }
 });