32 thoughts on “How to make website registration easier using facebook accounts

  1. Really a very good tutorial. Helped me a lot. I just had a doubt, if you could clarify that would be great.

    I tried your example and was able to fetch the parameters mentioned in the article except for the email id. Everything is working fine..no errors but unable to fetch email in the DB.

    any thoughts on that which would help me to solve the problem

  2. I dont know why mine hangs all the time. It asks permissions twice and then it goes to https://www.facebook.com/dialog/oauth/write and there comes error message that “This function is not available at the moment. Error processing the request. Try again later”. (There might be translation error i am reading it as finnish!). I have put everything in place. I wonder if facebook_auth.php file should have redirection url to facebook_auth.php or welcome.php? Same question to index.php? After all this it now goes to welcome.php and text says welcome !. So it does not receive name.

    • I will have to check this out and let you know. Some permissions or something might have changed since I wrote this tutorial.

      • I found the solution. My program had fallen in unpublished mode in facebook settings. All tough it is not understandable why program must be published so that admins can test it, but that solved my issue. No problem in your example. Works great now.

  3. Hi Aniri, it’s really a wonderful tutorial. I am following in my work. There is problem I found. I tested this tut’s code for 3 user. In 2 cases, I got email but in 1 case, I got an error “Undefined property: stdClass::$email”. However, in this case of error, I did not give second permission or something like that , what I forgot. For every users, it takes login permission for first time. When I tried second time, it does take any permission just get login and redirected. Is there any way to get permission for every-time. Then I think, which email is not returned what I could check to give permission again what I missed first time.

    However, many thanks for this tutorial.

  4. Hi , where are you getting the $code variable from? It is not created anywhere but then you pass it?

    Thanks, Aidan

  5. I m trying to put facebook login to my website but it is something different in facebook creating app_id and secrete. Am i something wrong .I am a really really beginner.

    • Hey! Since it’s an old article, some things might have changed in their interface. What exactly looks confusing?

  6. i have been trying to set this up.But not getting email and facebook id.Please let me know if anything has changed on this side.

    • Hey, yes there might have been changes since this is an old tutorial 🙁 What exactly is not working?

    • Hey! I haven’t had the chance to try out the play framework, so I can’t provide a tutorial now. But if I will get to try it out, I will try and also write the tutorial 🙂

  7. Hi
    Thank you for your tutorial. For e it is possible to add the new user in the database – but only with the ID. There is no username, email, date etc… in the DB. Have you a idea ?
    kind regards

  8. The $user only stores the name and the public id and doesnot store the email, user_location etc. I have mentioned it in scope.

    $token_url = “https://graph.facebook.com/oauth/access_token?” . “client_id=” . $app_id . “&redirect_uri=” . urlencode($my_url) . “&client_secret=” . $app_secret . “&code=” . $code . “&scope=public_profile,email,user_birthday,user_location”;

    Can you please tell me how can I get details like email id, user_birthday, user_location.
    Thanks in advance.

    • Hello,

      The $user variable should all you wanted since you added permissions for them. Did the permissions part work correctly and ask you for permissions? Are you getting any errors?

  9. hello,
    Your Tutorial is really helpful Thanks.
    I have done all the above mentioned but @file_get_contents($token_url); always returns false, please where am I getting it wrong ??
    This is my code

    //this action is to signup a user with facebook
    public function actionFbsignup($code){
    $app_id = ‘1155742141220098’;
    $app_secret = “nothing”;
    $my_url = “myurl”;
    $token_url = “https://graph.facebook.com/oauth/access_token?”. “client_id=” . $app_id .
    “&redirect_uri=” . urlencode($my_url). “&client_secret=” . $app_secret.
    “&code=” . $code. “&scope=publish_stream,email”;

    $response = @file_get_contents($token_url);
    // return var_dump($response);
    $params = null;
    parse_str($response, $params);
    //return var_dump($params);
    $graph_url = “https://graph.facebook.com/me?access_token=”. $params[‘access_token’];
    $model = json_decode(file_get_contents($graph_url));
    $accExist = User::findOne([‘facebook_id’ => $model->id]);

    At this stage, I get $params[‘access_token’] not defined
    Please I really need your help.

Leave a Reply

Your email address will not be published. Required fields are marked *