注册流程使用FB.login [英] Registration flow using FB.login

查看:365
本文介绍了注册流程使用FB.login的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



现在FBML的方式很好:

 < fb:login-button registration-url =<?php echo $ config [base_url];?> test.php = 小 >< / FB:登录按钮> 

点击上面的按钮以上代码触发div显示注册插件

  FB.getLoginStatus(function(response){
if(response.status ==='not_authorized'){
//显示注册表单
document.getElementById('reg')。style.display =block;
}
});

//注册表格放在div
< div style =display:none; width:540px; position:relative; margin:0 auto; ID = REG >
< fb:registration fields =name,birthday,gender,location,email
redirect uri =http://app.sunosunaao.com/test.phpwidth =530> ;
< / fb:registration>
< / div>

但是,一旦用户从FB.login()登录,有没有办法显示上述div?因为如果我使用FB.login(),它直接进入Facebook Permission页面,一旦连接到以下函数中的条件是

  response.status ==='connected'

因此注册插件不被触发

FB.getLoginStatus(function(response){
if(response .status ==='not_authorized'){
//显示注册表单
document.getElementById('reg')。style.display =block;
}
} );

任何关于我如何减轻的想法

 < fb:login-button registration-url =<?php echo $ config [base_url];?> test.phpsize =small> < / FB:登录按钮>用FB.login(); 


解决方案

您可以在JavaScript代码中附加事件,在这篇文章中描述
http://developers.facebook.com/blog/post / 534 /

  FB.Event.subscribe('auth.login',function(response){
//此代码在登录成功后执行
});
FB.Event.subscribe('auth.logout',function(response){
//此代码在注销成功后执行
});

我希望这将有所帮助。


I want to change Login + registration flow with FB Javascript SDK using FB.login().

Now FBML way wroks fine:

<fb:login-button registration-url="<?php echo $config["base_url"]; ?>test.php" size="small"></fb:login-button>

on clicking the button above the following code triggers the div to show registration plugin

FB.getLoginStatus(function(response) {
        if (response.status === 'not_authorized') {
          // show registration form   
           document.getElementById('reg').style.display = "block";
          }
         });     

// registration form placed in a div 
<div style="display:none;width:540px;position:relative;margin:0 auto;" id="reg">     
<fb:registration fields="name,birthday,gender,location,email" 
redirect uri="http://app.sunosunaao.com/test.php" width="530">
</fb:registration>
</div>

But Is there a way to show the above div once user logged in from FB.login()? Because If I use FB.login(), it directly goes to Facebook Permission page, and once connected the condition in the following function is

response.status === 'connected'

hence the registration plugin is not triggered 

FB.getLoginStatus(function(response) {
        if (response.status === 'not_authorized') {
          // show registration form   
           document.getElementById('reg').style.display = "block";
          }
         });    

Any Idea as to how i can subtitute

<fb:login-button registration-url="<?php echo $config["base_url"]; ?>test.php" size="small"></fb:login-button> with FB.login();

解决方案

You can attach events in your javascript code like what was described in this post here http://developers.facebook.com/blog/post/534/

    FB.Event.subscribe('auth.login', function(response) {
      // this code is executed after login success
    });
    FB.Event.subscribe('auth.logout', function(response) {
      // this code is executed after logout success 
    });

I hope that will help.

这篇关于注册流程使用FB.login的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆