HEX
Server: Apache
System: Linux hp3-stn-1011028.hostingp3.local 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: csh958633 (951153)
PHP: 8.3.30
Disabled: shell_exec,exec,system,popen,set_time_limit
Upload Files
File: /home/hp3-linc5-nfs2-z/664/1174664/user/htdocs/research/logintofacebook.php
<!DOCTYPE html>
<html lang="en">
<head>

  <!-- Basic Page Needs
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta charset="utf-8">
  <title>Megan Knight - University of Hertfordshire - Social Media Research</title>
  <meta name="description" content="">
  <meta name="author" content="">

  <!-- Mobile Specific Metas
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- FONT
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">

  <!-- CSS
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/skeleton.css">

  <!-- Favicon
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link rel="icon" type="image/png" href="images/favicon.png">

</head>
<body>

  <div class="container">
    <div class="row">
      <div class="one-half column" style="margin-top: 25%">

<h35>Megan Knight - University of Hertfordshire</h5>



<?php


error_reporting(E_ALL);
ini_set('display_errors', 1);


// Pass session data over.
session_start();
$userid=$_GET['userid'];

//echo $userid;
 
// Include the required dependencies.
require( '../facebook-php-sdk-5/src/Facebook/autoload.php' );

// Initialize the Facebook PHP SDK v5.
$fb = new Facebook\Facebook([
  'app_id'                => '2092932830933312',
  'app_secret'            => '282303ece01dd46a3436dd94606c06ca',
  'default_graph_version' => 'v2.9',
  
]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['public_profile','user_religion_politics', 'user_birthday', 'user_posts', 'user_likes', 'user_actions.news']; // optional
//$permissions = array(
    //'public_profile',
    //'user_location',
    //'user_birthday',
	//'user_religion_politics',
	//'user-posts'
//);
 
// Get login URL
 $callback    = "http://www.meganknight.uk/research/getdatafromfacebook.php?userid='$userid'";
//$callback    = "http://localhost/research/getdatafromfacebook.php?userid='$userid'";
$loginUrl    = $helper->getLoginUrl($callback, $permissions);
$helper = $fb->getRedirectLoginHelper();


if (isset($_GET['state'])) {
    $helper->getPersistentDataHandler()->set('state', $_GET['state']);
}
try {
  $accessToken = $helper->getAccessToken();
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  // There was an error communicating with Graph
  echo $e->getMessage();
  exit;
}
 
if (isset($accessToken)) {
  // User authenticated your app!
  // Save the access token to a session and redirect
  $_SESSION['facebook_access_token'] = (string) $accessToken;
  // Log them into your web framework here . . .
  echo 'Successfully logged in!';
  
$cilent = $fb->getOAuth2Client();
   
  exit;
} elseif ($helper->getError()) {

  // The user denied the request
  // You could log this data . . .
  var_dump($helper->getError());
  var_dump($helper->getErrorCode());
  var_dump($helper->getErrorReason());
  var_dump($helper->getErrorDescription());
  // You could display a message to the user
  // being all like, "What? You don't like me?"
  exit;
} else {
	echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';	
}
 
// If they've gotten this far, they shouldn't be here
http_response_code(400);
exit;

?>
     </div>
    </div>
  </div>
</html>