简体   繁体   English

新的Facebook登录指南

[英]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. 在用户单击登录按钮之后,Facebook曾经有一个可以在其中输入URL的地方,但是在新的设置页面上似乎已经消失了。

Is there any guide available that is based on the new updates on facebook? 是否有基于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. 我正在建立一个网站,并希望使用Facebook登录名来使用户登录到该站点并从我的数据库中加载他们的记录。

Below is solution for your problem step by step :) 以下是逐步解决您的问题的方法:)

You can solve your problem in 5 Steps 您可以通过5个步骤解决您的问题

Step 1 第1步

Create a new facebook app using the link and note its App ID/API Key 使用链接创建一个新的Facebook应用,并记下其应用ID / API密钥

Step 2 第2步

use your App ID/API Key which you note in Step 1 使用您在步骤1中记下的App ID / API密钥

The following code will load and initialize the JavaScript SDK with all common options. 以下代码将使用所有常用选项加载并初始化JavaScript SDK。 Replace YOUR_APP_ID and WWW.YOUR_DOMAIN.COM with the appropriate values. 用适当的值替换YOUR_APP_IDWWW.YOUR_DOMAIN.COM The best place to put this code is right after the opening <body> tag. 放置此代码的最佳位置是在<body>标记之后。

<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 使用以下代码创建一个channel.html文件

  <?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. 将XML名称空间添加到文档的<html>标记中。 This is necessary for XFBML to work in earlier versions of Internet Explorer. 为了使XFBML在早期版本的Internet Explorer中工作,这是必需的。

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

Step 5 第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: 将JavaScript SDK加载到页面中并使用appId对其进行初始化后,只需使用div class元素将“登录按钮”添加到页面中,如下所示:

<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 在这里您可以获取JavaScript,频道文件详细信息和其他详细信息

Thanks... 谢谢...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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