Skip to content

harryngdev/facebook_google_api_login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduce

  • Facebook/Google API
  • Form login with Facebook/Google accounts in PHP
  • Clase redes Servidor HTTP con XAMPP
  • How to enable SSL (HTTPS protocol) with XAMPP in a local PHP project

Installation

Set up config in modules/connect_db.php:

$host = '';
$user_name = '';
$password = '';
$database = '';

$conn = mysqli_connect($host, $user_name, $password, $database);

if (!$conn) {
    echo "Connection failed: ".mysqli_connect_error();
}

Create Virtual Host Name:

  • Step 1: Access to C:\xampp\apache\conf\httpd.conf, and search for the code below, remove comment at line 2 if it is available
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
  • Step 2: Access to C:\xampp\apache\conf\extra\httpd-vhosts.conf, and add the code below
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/api_login"
    ServerName api_login.com
</VirtualHost>

Note, DocumentRoot is path to the project directory and ServerName is the link that leads you want to put on the website

  • Step 3: Access to C:\Windows\System32\drivers\etc\hosts, and add your host
127.0.0.1 api_login.com

Note, host must have the same name as ServerName above


Configuring SSL HTTPS in XAMPP:

  • Step 1: Create crt directory in C:\xampp\apache\, then copy cert.conf, document.txt and make-cert.bat in the SSL directory of Project, and paste in there
  • Step 2: Open cert.conf, and correct the lines below
...
commonName_default          = api_login.com
...
DNS.1       = api_login.com
  • Step 3: Run make-cert.bat, then enter your domain, and press the enter key until the end

Note, folder "api_login.com" will be created

  • Step 4: Run server in the api_login.com directory, and follow these steps below
Install Certificate -> Local Machine -> Next -> Place all certificates in the following store -> Browse -> Trusted Root Certification Authorities -> OK -> Next -> Finish -> OK
  • Step 5: Copy the content of document.txt, and paste into C:\xampp\apache\conf\extra\httpd-vhosts.conf
 <VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/api_login"
    ServerName api_login.com
    ServerAlias *.api_login.com
 </VirtualHost>
 <VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs/api_login"
    ServerName api_login.com
    ServerAlias *.api_login.com
    SSLEngine on
    SSLCertificateFile "crt/api_login.com/server.crt"
    SSLCertificateKeyFile "crt/api_login.com/server.key"
 </VirtualHost>

Create a Facebook login project:

  • Step 1: Visit Developers Facebook to create an account, then create a facebook login application
  • Step 2: Paste the path to your website created above into fields Privacy Policy URL and Site URL
  • Step 3: Paste the path of fb_callback.php into filed Valid OAuth Redirect URIs in settings of your products
  • Step 4: Once done, go to settings and copy the App ID, App Secret and API Version, then paste into fb_config.php in modules/fb_config.php as below
<?php
    $fb = new Facebook\Facebook([
        'app_id' => '012345678987654',
        'app_secret' => 'password',
        'default_graph_version' => 'v10.0'
    ]);
?>

Create a Google login project:

  • Step 1: Visit Google Cloud Platform to create an account, then create a google login application
  • Step 2: Once done, go to credentials and copy the Client ID and Client secret, then paste into gg_source.php in modules/gg_source.php as below
<?php
    ...
    $client_id = '12312312-v2131938712093791';
    $client_secret = 'kj1231298casdjkh1';
    $redirect_uri = 'https://api_login.com';
    ...
?>

Path

Index:

https://api_login.com/

Connect with me:

nvanha.com nvanha | Facebook nvanha | Instagram