skip to Main Content

I am trying to implement social login on my website. I am requesting user-email from facebook API and want to pre-populate email field in one of the form with that email. How do I do it?

2

Answers


  1. Chosen as BEST ANSWER

    I found it. I am new to programming so asked such a newbie question. I passed a hidden input parameter in form for email and assigned the value of email that I received from facebook to the input parameter.


  2. You can refer to this documentation here. After you get the email from the response, you can then store it into a server session, pass it to the next web page where your forms are located or anything you want to do with it

    FB.login(function(response) {
        if (response.authResponse) {
         console.log('Welcome!  Fetching your information.... ');
         FB.api('/me', function(response) {
           console.log('Good to see you, ' + response.name + '.');
           console.log('email: ' + response.email);
         });
        } else {
         console.log('User cancelled login or did not fully authorize.');
        }
    }, {scope: 'email,user_likes'});
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search