PHP Professional এবং Zend Certified PHP Engineer (ZCPE ) Course এ সীমিত সংখ্যক আসন বাকি আছে। আগ্রহীদেরকে অতিসত্বর মাসুদ আলম স্যার এর সাথে যোগাযোগ করার জন্য অনুরোধ করা যাচ্ছে। স্যার এর মোবাইল নম্বর : ০১৭২২ ৮১ ৭৫ ৯১
22 comments on “Adding Facebook Login feature to any Website
  1. bro i am getting errors, at my localhost
    Warning: Header may not contain more than a single header, new line detected. in C:\xampp\htdocs\fb\login_facebook.php on line 24

    • on line 20 to 24 you’ll see the code is something like this:

      header(“location:

      https://www.facebook.com/dialog/oauth?client_id=$app_id&scope=email&redirect_uri=$redirect_uri&state=$state

      “);

      just remove all the new lines and put all this code into one line as so:

      header(“location: https://www.facebook.com/dialog/oauth?client_id=$app_id&scope=email&redirect_uri=$redirect_uri&state=$state“);

      Some PHP installations throw an error in this situation and some Don’t ……
      Hope this helped,
      Good Luck…:)

  2. Spot on with this write-up, I truly believe this site needs a great deal more attention. I’ll probably be back again to read more, thanks for the info!

  3. really nice tutorial and worked successfully.
    I want to login directly to my site through facebook and i dont want to check database.for this what i do in this code.

    • Check on Line 66:
      authenticate_user($data[“email”]);

      remove this line and replace it with:
      $access_token = get_access_token();
      $userData = getData($access_token);

      Now you have a variable named $userData with the user’s Facebook ID, Email Address and Name, use this information to instantly signup or temporarily login the user into your site……

  4. Hmm is anyone else experiencing problems with the pictures on this blog loading?
    I’m trying to figure out if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

    • Sir, rest assured the blog’s images are working fine. Modify your Browser settings, check your internet connection, or at least clear your cache and reload the page(Ctrl+F5).

  5. siri am getting errors, at my localhost
    its cant redirect on facebook page
    this is a my login facebook.php code
    query(“SELECT id FROM users WHERE email='”.$email.”‘”);
    $array = $query->fetch_assoc();
    if($query->num_rows==1){
    $_SESSION[“user”] = $array[“id”];
    header(“location: index.php”);
    }else{
    header(“location: index.php”);
    }
    }

    if(isset($_REQUEST[“error”])){
    header(“location: index.php”);
    }elseif(isset($_REQUEST[“code”])){

    if(isset($_REQUEST[“state”]) && $_REQUEST[“state”]==$_SESSION[“state”]){
    $access_token = get_access_token();
    $data = getData($access_token);

    authenticate_user($data[“email”]);
    }

    }else{
    dialog();
    }
    ?>
    pls help me

    • Sorry! The fault is mine. On line 20 to 24 in my code, you’ll see the code is something like this:

      header(“location:

      https://www.facebook.com/dialog/oauth?client_id=$app_id&scope=email&redirect_uri=$redirect_uri&state=$state

      “);

      this code is a part of the dialog() function.
      just remove all the new lines and put all this code into one line as so:

      header(“location: https://www.facebook.com/dialog/oauth?client_id=$app_id&scope=email&redirect_uri=$redirect_uri&state=$state“);

      Hope this helped,
      Good Luck…:)

  6. It is actually a great and useful piece of information. I’m glad that you shared this
    helpful information with us. Please keep us informed like this.
    Thank you for sharing.

  7. Salam, Brother a nice effort from you. I appreciate. I downloaded and run this application but when I execute this application using following link, it shows nothing:

    http://localhost/facebook-site/login_facebook.php

    I have all done all settings which you mentioned in your tutorial.

    Thanks

Leave a Reply

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