Completed
Push — master ( 0b31bd...27ce5d )
by Rakesh
06:22 queued 02:47
created

fb-callback.php (1 issue)

Labels
Severity
1
<html>
2
<head>
3
<meta name="viewport" content="width=device-width, initial-scale=1">
4
<title>All Albums | Facebook | Download, SlideShow & Backup to Google Drive</title>
5
<link rel="stylesheet" type="text/css" href="lib/CSS/slider.css">
6
</head>
7
<body>
8
<?php
9
session_start();
10
require_once 'appconfig.php';
11
$fb = new Facebook\Facebook([
12
<<<<<<< HEAD
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_SL, expecting ',' or ']' on line 12 at column 0
Loading history...
13
  'app_id' => $appId, // variable with Facebook App ID
14
  'app_secret' => $appSecret,
15
  'default_graph_version' => 'v3.3',
16
  ]);
17
$helper = $fb->getRedirectLoginHelper();
18
=======
19
    'app_id' => $appId, // variable with My Facebook App ID
20
    'app_secret' => $appSecret,
21
    'default_graph_version' => 'v3.2',
22
    ]);
23
$helper = $fb->getRedirectLoginHelper();
24
if(isset($_GET['state'])){
25
    $helper->getPersistentDataHandler()->set('state',$_GET['state']);
26
}
27
>>>>>>> 85e358e0c342f50861ef32c55d7303292e8d8f01
28
try {
29
    $accessToken = $helper->getAccessToken();
30
} catch(Facebook\Exceptions\FacebookResponseException $e) {
31
    // When Graph returns an error
32
    echo 'Graph returned an error: ' . $e->getMessage();
33
    exit;
34
} catch(Facebook\Exceptions\FacebookSDKException $e) {
35
    // When validation fails or other local issues
36
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
37
    exit;
38
}
39
if (!isset($accessToken)) {
40
    if ($helper->getError()) {
41
    header('HTTP/1.0 401 Unauthorized');
42
    echo "Error: " . $helper->getError() . "\n";
43
    echo "Error Code: " . $helper->getErrorCode() . "\n";
44
    echo "Error Reason: " . $helper->getErrorReason() . "\n";
45
    echo "Error Description: " . $helper->getErrorDescription() . "\n";
46
    } else {
47
    header('HTTP/1.0 400 Bad Request');
48
    echo 'Bad request hihihih';
49
    }
50
    exit;
51
}
52
// Logged in
53
echo '<h3>Access Token</h3>';
54
var_dump($accessToken->getValue());
55
// The OAuth 2.0 client handler helps us manage access tokens
56
$oAuth2Client = $fb->getOAuth2Client();
57
// Get the access token metadata from /debug_token
58
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
59
echo '<h3>Facebook Photos Challenge</h3>';
60
var_dump($tokenMetadata);
61
// Validation (these will throw FacebookSDKException's when they fail)
62
$tokenMetadata->validateAppId($appId); // My Facebook App ID
63
// If you know the user ID this access token belongs to, you can validate it here
64
//$tokenMetadata->validateUserId('123');
65
$tokenMetadata->validateExpiration();
66
if (! $accessToken->isLongLived()) {
67
    // Exchanges a short-lived access token for a long-lived one
68
    try {
69
    $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
70
    } catch (Facebook\Exceptions\FacebookSDKException $e) {
71
    echo "<p>Error getting long-lived access token: " . $e->getMessage() . "</p>\n\n";
72
    exit;
73
    }
74
    echo '<h3>Long-lived</h3>';
75
    var_dump($accessToken->getValue());
76
}
77
78
$_SESSION['fb_access_token'] = (string)$accessToken;
79
80
header('Location: member.php');
81
?>
82
</body>
83
</html>