Implementing Facebook Login

I have a website where I want to implement a facebook login tool. I looked through the facebook developer pages, but they are unclear and cannot fully understand.

My site is a php-mysql application, I already have a registration process for new users on my website, but I want users to be able to log in with their facebook id, as well as once they are logged in I want to save their identifier in my mysql database, to determine them next time.

I went through similar topics in SO, but couldn't crack it. If anyone can connect me with a step-by-step clear guide to implement this on my website.

+4
source share
2 answers

Just did a quick google search on this subject and found the following blog post:. This seems to be about setting up FB input in php.

The message says that when calling $facebook->require_login(); it asks the user for a login using FB, and then, upon successful registration, returns the FB ID so you can write something like $fb_id = $facebook->require_login(); and then save $fb_id .

Here is a complete hello world example - it’s best to read a blog post for a more complete guide:

 <?php /* include the PHP Facebook Client Library to help with the API calls and make life easy */ require_once('facebook/client/facebook.php'); /* initialize the facebook API with your application API Key and Secret */ $facebook = new Facebook(YOUR_API_KEY,YOUR_SECRET_CODE); /* require the user to be logged into Facebook before using the application. If they are not logged in they will first be directed to a Facebook login page and then back to the application page. require_login() returns the user unique ID which we will store in fb_user */ $fb_user = $facebook->require_login(); /* now we will say: Hello USER_NAME! Welcome to my first application! */ ?> Hello <fb:name uid='<?php echo $fb_user; ?>' useyou='false' possessive='true' />! Welcome to my first application! <?php /* We'll also echo some information that will help us see what going on with the Facebook API: */ echo "<pre>Debug:" . print_r($facebook,true) . "</pre>"; ?> 
-1
source

Source: https://habr.com/ru/post/1384300/


All Articles