-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddTab2.php
65 lines (59 loc) · 2.49 KB
/
addTab2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include("../mainframe.php");
session_start();
require_once __DIR__ . '/src/Facebook/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => '507994349541183',
'app_secret' => '086f3329a66b06d5e9c5f842fd7e218e',
'default_graph_version' => 'v2.11',
]);
$helper = $fb->getPageTabHelper();
try {
$accessToken = $helper->getAccessToken();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
}
if (isset($accessToken)) {
if (isset($_SESSION['facebook_access_token'])) {
$fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
} else {
$_SESSION['facebook_access_token'] = (string) $accessToken;
$oAuth2Client = $fb->getOAuth2Client();
$longLivedAccessToken = $oAuth2Client->getLongLivedAccessToken($_SESSION['facebook_access_token']);
$_SESSION['facebook_access_token'] = (string) $longLivedAccessToken;
$fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
}
if (isset($_GET['code'])) {
header('Location: ./');
}
try {
$signedRequest = $helper->getSignedRequest();
$signedRequest=$signedRequest->getPayload();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
session_destroy();
header("Location: ./");
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
if (!empty($signedRequest)){
$pageid = $signedRequest[page][id];
$pages = $functions->db->query("SELECT * FROM page_tab WHERE page_id='$pageid' ORDER BY id DESC LIMIT 1");
foreach ($pages as $page) {
if ($page['doc_id'] != ''){
$_GET['id']=$page['doc_id'];
include("../appointment_detail.php");
} else if ($page['clinic_id'] != ''){
$_GET['cid']=$page['clinic_id'];
include("../appointment_detail.php");
}
}
}
}
?>