Facebook Connect via Javascript does not close and does not pass the session identifier

I am trying to authenticate users via Facebook Connect using a custom Javascript button:

<form>
<input type="button" value="Connect with Facebook" onclick="window.open('http://www.facebook.com/login.php?api_key=XXXXX&extern=1&fbconnect=1&req_perms=publish_stream,email&return_session=0&v=1.0&next=http%3A%2F%2Fwww.example.com%2Fxd_receiver.htm&fb_connect=1&cancel_url=http%3A%2F%2Fwww.example.com%2Fregister%2Fcancel', '_blank', 'top=442,width=480,height=460,resizable=yes', true)" onlogin='window.location="/register/step2"' />
</form>

I can authenticate users. However, after authentication, the pop-up window remains open and the main window is not directed anywhere. In fact, this is a popup that goes to "/ register / step2"

How can I make the login window close as expected and pass the facebook session id to / register / step 2?

Thank!

+3
source share
4 answers

, JS SDK ( , onlogin , - SDK). JS SDK. XFBML <fb:login-button>:

<fb:login-button perms="read_stream"></fb:login-button>

.

+1

Facebook URL Django? , URLconf :

url(r'^facebook/setup/$', facebook_complete_reg, name="facebook_setup"),

'facebook_complete_reg' 'setup' django-facebookconnect. , , " Facebook" .

, , JavaSript. :

{% load facebook_tags %}
{% facebook_js %}
{% initialize_facebook_connect %}

'show_connect_button', , , .

, , , JavaScript - . ?

0

, .

To do this, take a step-by-step tutorial .

0
source

you can use the xd_receiver.html file with the following code:

<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>

put it in the template folder, and then put this code where you want the button to be on your application page:

    <script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript">
    </script>
    <script type="text/javascript">
      FB.init("API_KEY", "/xd_receiver.html",{ permsToRequestOnConnect : "email,publish_stream,photo_upload,offline_access" });

    function facebook_login() {
       window.location ="/register/step2"
    }
    </script>
    <fb:login-button onlogin="facebook_login();"></fb:login-button>

and add one url to get xd_receiver and create a view for it

hope this helps you

thank

Ansh j

0
source

Source: https://habr.com/ru/post/1742873/


All Articles