简体   繁体   中英

New Facebook login guide

Facebook used to have a place where we can enter the URL after the user has clicked on the login button, but that seems to be gone on the new settings page.

Is there any guide available that is based on the new updates on facebook? I am building a website and would like to use the facebook login to get users login to the site and load their records from my database.

Below is solution for your problem step by step :)

You can solve your problem in 5 Steps

Step 1

Create a new facebook app using the link and note its App ID/API Key

Step 2

use your App ID/API Key which you note in Step 1

The following code will load and initialize the JavaScript SDK with all common options. Replace YOUR_APP_ID and WWW.YOUR_DOMAIN.COM with the appropriate values. The best place to put this code is right after the opening <body> tag.

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
FB.init({
  appId      : 'YOUR_APP_ID', // App ID
  channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
  status     : true, // check login status
  cookie     : true, // enable cookies to allow the server to access the session
  xfbml      : true  // parse XFBML
  oauth      : true,
});

// Additional initialization code here
  };

  // Load the SDK Asynchronously
  (function(d){
 var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>

Step 3

Create a channel.html file with the below code

  <?php
    $cache_expire = 60*60*24*365;
    header("Pragma: public");
    header("Cache-Control: max-age=".$cache_expire);
    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
  ?>
  <script src="//connect.facebook.net/en_US/all.js"></script>

Step 4
Add an XML namespace to the <html> tag of your document. This is necessary for XFBML to work in earlier versions of Internet Explorer.

<html xmlns:fb="http://ogp.me/ns/fb#">

Step 5

Once you have loaded the JavaScript SDK into your page and initialized it with your appId, you simply add the Login Button to your page using the div class element as shown below:

<div class="fb-login-button">Login with Facebook</div>

You can read all the above in details where the almost all information is get below is the links

  1. here you can get javascript, channel file details and other details

Thanks...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM