使用 FB.login 的註冊流程 (Registration flow using FB.login)


問題描述

使用 FB.login 的註冊流程 (Registration flow using FB.login)

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

參考解法

方法 1:

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. 

(by Ujwal AbhishekWardi)

參考文件

  1. Registration flow using FB.login (CC BY-SA 3.0/4.0)

#login #facebook






相關問題

只允許 oracle db 登錄到特定的應用程序? (Allowing oracle db login only to specific application?)

使用 FB.login 的註冊流程 (Registration flow using FB.login)

asp.net c# sistem login (asp.net c# login system)

Rails 設計登錄不工作 (Rails devise sign in not working)

我在 cakephp 2.4 中遇到了登錄頁面 (I'm getting stuck with login page in cakephp 2.4)

如何刪除特定用戶的會話登錄 (How to remove session login for specific user)

有沒有標準的asp.net認證授權登錄系統? (Is there a standard asp.net authentication authorization login system?)

所有這些網絡平台如何實現不需要用戶反复登錄的長時間登錄會話? (How do all these web platforms achieve a long-time login session that does not require the user to login over and over again?)

Util-Linux 登錄不使用影子密碼 (Util-Linux Login not working with shadow password)

Android Webview Facebook 登錄 (Android Webview Facebook Login)

重置 Bookstack 憑據 (Reset Bookstack Credentials)

輸入正確的詳細信息且未顯示錯誤後,登錄頁面未重定向到 index.php (Login in page not redirecting to index.php after entering correct details with no error displayed)







留言討論