| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/uatb2c.hellogtx.com/Facebook/ |
Upload File : |
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
session_start();
require_once 'init.php';
$baseUrl = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
// added in v4.0.0
require_once 'autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// define('facebook_client_secret','89c48709904d9184ab54121cf58c7cbb');
// define('facebook_app_id','1052572098097230');
// init app with app id and secret
FacebookSession::setDefaultApplication(facebook_app_id,facebook_client_secret);
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper($baseUrl.'/Facebook/index.php');
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
$session = $ex;
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
//echo"<pre>";print_r($session);die;
// see if we have a session
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me?fields=id, first_name, last_name, email, picture.type(large)' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbfirst_name = $graphObject->getProperty('first_name'); // To Get Facebook full name
$fblast_name = $graphObject->getProperty('last_name'); // To Get Facebook full name
$femail = $graphObject->getProperty('email'); // To Get Facebook email ID
$data = array(
'fbid'=> $fbid,
'ffirst_name'=> $fbfirst_name,
'flast_name'=> $fblast_name,
'femail'=> $femail,
'profilephoto'=> 'https://graph.facebook.com/'.$fbid,
);
//print_r($data);die('ll');
$_SESSION['Fbdata'] = $data;
/* ---- Session Variables -----*/
// $_SESSION['FBID'] = $fbid;
// $_SESSION['FULLNAME'] = $fbfullname;
// $_SESSION['EMAIL'] = $femail;
/* ---- header location after session ----*/
header("Location: check.php");
} else {
$permissions = ['email'];
$loginUrl = $helper->getLoginUrl($permissions);
header("Location: ".$loginUrl);
}
?>