Passed
Push — master ( bfeae7...87a9ab )
by Rakesh
01:57
created
fb-callback.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,41 +1,41 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(!session_id()) {
3
-  session_start();
3
+    session_start();
4 4
 }
5 5
 require_once 'appconfig.php';
6 6
 
7 7
 $fb = new Facebook\Facebook([
8
-  'app_id' => $appId, // variable with My Facebook App ID
9
-  'app_secret' => $appSecret,
10
-  'default_graph_version' => 'v3.2',
11
-  ]);
8
+    'app_id' => $appId, // variable with My Facebook App ID
9
+    'app_secret' => $appSecret,
10
+    'default_graph_version' => 'v3.2',
11
+    ]);
12 12
 $helper = $fb->getRedirectLoginHelper();
13 13
 if(isset($_GET['state'])){
14
-  $helper->getPersistentDataHandler()->set('state',$_GET['state']);
14
+    $helper->getPersistentDataHandler()->set('state',$_GET['state']);
15 15
 }
16 16
 try {
17
-  $accessToken = $helper->getAccessToken();
17
+    $accessToken = $helper->getAccessToken();
18 18
 } catch(Facebook\Exceptions\FacebookResponseException $e) {
19
-  // When Graph returns an error
20
-  echo 'Graph returned an error: ' . $e->getMessage();
21
-  exit;
19
+    // When Graph returns an error
20
+    echo 'Graph returned an error: ' . $e->getMessage();
21
+    exit;
22 22
 } catch(Facebook\Exceptions\FacebookSDKException $e) {
23
-  // When validation fails or other local issues
24
-  echo 'Facebook SDK returned an error: ' . $e->getMessage();
25
-  exit;
23
+    // When validation fails or other local issues
24
+    echo 'Facebook SDK returned an error: ' . $e->getMessage();
25
+    exit;
26 26
 }
27 27
 if (! isset($accessToken)) {
28
-  if ($helper->getError()) {
28
+    if ($helper->getError()) {
29 29
     header('HTTP/1.0 401 Unauthorized');
30 30
     echo "Error: " . $helper->getError() . "\n";
31 31
     echo "Error Code: " . $helper->getErrorCode() . "\n";
32 32
     echo "Error Reason: " . $helper->getErrorReason() . "\n";
33 33
     echo "Error Description: " . $helper->getErrorDescription() . "\n";
34
-  } else {
34
+    } else {
35 35
     header('HTTP/1.0 400 Bad Request');
36 36
     echo 'Bad request';
37
-  }
38
-  exit;
37
+    }
38
+    exit;
39 39
 }
40 40
 // Logged in
41 41
 echo '<h3>Access Token</h3>';
@@ -52,27 +52,27 @@  discard block
 block discarded – undo
52 52
 //$tokenMetadata->validateUserId('123');
53 53
 $tokenMetadata->validateExpiration();
54 54
 if (! $accessToken->isLongLived()) {
55
-  // Exchanges a short-lived access token for a long-lived one
56
-  try {
55
+    // Exchanges a short-lived access token for a long-lived one
56
+    try {
57 57
     $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
58
-  } catch (Facebook\Exceptions\FacebookSDKException $e) {
58
+    } catch (Facebook\Exceptions\FacebookSDKException $e) {
59 59
     echo "<p>Error getting long-lived access token: " . $e->getMessage() . "</p>\n\n";
60 60
     exit;
61
-  }
62
-  echo '<h3>Long-lived</h3>';
63
-  var_dump($accessToken->getValue());
61
+    }
62
+    echo '<h3>Long-lived</h3>';
63
+    var_dump($accessToken->getValue());
64 64
 }
65 65
 
66 66
 //$_SESSION['fb_access_token'] = (string) $accessToken;
67 67
 try {
68
-  // Returns a `Facebook\FacebookResponse` object
69
-  $response = $fb->get('/me?fields=id,name', $accessToken);
68
+    // Returns a `Facebook\FacebookResponse` object
69
+    $response = $fb->get('/me?fields=id,name', $accessToken);
70 70
 } catch(Facebook\Exceptions\FacebookResponseException $e) {
71
-  echo 'Graph returned an error: ' . $e->getMessage();
72
-  exit;
71
+    echo 'Graph returned an error: ' . $e->getMessage();
72
+    exit;
73 73
 } catch(Facebook\Exceptions\FacebookSDKException $e) {
74
-  echo 'Facebook SDK returned an error: ' . $e->getMessage();
75
-  exit;
74
+    echo 'Facebook SDK returned an error: ' . $e->getMessage();
75
+    exit;
76 76
 }
77 77
 $user = $response->getGraphUser();
78 78
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!session_id()) {
2
+if (!session_id()) {
3 3
   session_start();
4 4
 }
5 5
 require_once 'appconfig.php';
@@ -10,21 +10,21 @@  discard block
 block discarded – undo
10 10
   'default_graph_version' => 'v3.2',
11 11
   ]);
12 12
 $helper = $fb->getRedirectLoginHelper();
13
-if(isset($_GET['state'])){
14
-  $helper->getPersistentDataHandler()->set('state',$_GET['state']);
13
+if (isset($_GET['state'])) {
14
+  $helper->getPersistentDataHandler()->set('state', $_GET['state']);
15 15
 }
16 16
 try {
17 17
   $accessToken = $helper->getAccessToken();
18
-} catch(Facebook\Exceptions\FacebookResponseException $e) {
18
+} catch (Facebook\Exceptions\FacebookResponseException $e) {
19 19
   // When Graph returns an error
20 20
   echo 'Graph returned an error: ' . $e->getMessage();
21 21
   exit;
22
-} catch(Facebook\Exceptions\FacebookSDKException $e) {
22
+} catch (Facebook\Exceptions\FacebookSDKException $e) {
23 23
   // When validation fails or other local issues
24 24
   echo 'Facebook SDK returned an error: ' . $e->getMessage();
25 25
   exit;
26 26
 }
27
-if (! isset($accessToken)) {
27
+if (!isset($accessToken)) {
28 28
   if ($helper->getError()) {
29 29
     header('HTTP/1.0 401 Unauthorized');
30 30
     echo "Error: " . $helper->getError() . "\n";
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 // If you know the user ID this access token belongs to, you can validate it here
52 52
 //$tokenMetadata->validateUserId('123');
53 53
 $tokenMetadata->validateExpiration();
54
-if (! $accessToken->isLongLived()) {
54
+if (!$accessToken->isLongLived()) {
55 55
   // Exchanges a short-lived access token for a long-lived one
56 56
   try {
57 57
     $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 try {
68 68
   // Returns a `Facebook\FacebookResponse` object
69 69
   $response = $fb->get('/me?fields=id,name', $accessToken);
70
-} catch(Facebook\Exceptions\FacebookResponseException $e) {
70
+} catch (Facebook\Exceptions\FacebookResponseException $e) {
71 71
   echo 'Graph returned an error: ' . $e->getMessage();
72 72
   exit;
73
-} catch(Facebook\Exceptions\FacebookSDKException $e) {
73
+} catch (Facebook\Exceptions\FacebookSDKException $e) {
74 74
   echo 'Facebook SDK returned an error: ' . $e->getMessage();
75 75
   exit;
76 76
 }
77 77
 $user = $response->getGraphUser();
78 78
 
79
-echo 'ID: ' . $user['id'] ;
79
+echo 'ID: ' . $user['id'];
80 80
 echo '<br/ >Welcome, ' . $user['name'];
81 81
 echo '<a href="logout.php" > Logout </a>';
82 82
 
@@ -93,22 +93,22 @@  discard block
 block discarded – undo
93 93
 
94 94
 // Render all photo albums
95 95
 echo "<br/><br/>";
96
-foreach($fbAlbumData as $data){
97
-    $id = isset($data['id'])?$data['id']:'';
98
-    $name = isset($data['name'])?$data['name']:'';
99
-    $description = isset($data['description'])?$data['description']:'';
100
-    $link = isset($data['link'])?$data['link']:'';
101
-    $cover_photo_id = isset($data['cover_photo']['id'])?$data['cover_photo']['id']:'';
102
-    $count = isset($data['count'])?$data['count']:'';
96
+foreach ($fbAlbumData as $data) {
97
+    $id = isset($data['id']) ? $data['id'] : '';
98
+    $name = isset($data['name']) ? $data['name'] : '';
99
+    $description = isset($data['description']) ? $data['description'] : '';
100
+    $link = isset($data['link']) ? $data['link'] : '';
101
+    $cover_photo_id = isset($data['cover_photo']['id']) ? $data['cover_photo']['id'] : '';
102
+    $count = isset($data['count']) ? $data['count'] : '';
103 103
     
104 104
     $pictureLink = "slideshow.php?album_id={$id}&album_name={$name}";
105 105
     echo "<a href='{$pictureLink}'>";
106
-    $cover_photo_id = (!empty($cover_photo_id ))?$cover_photo_id : 123456;
106
+    $cover_photo_id = (!empty($cover_photo_id)) ? $cover_photo_id : 123456;
107 107
     echo "<img width=100px height=100px src='https://graph.facebook.com/v3.2/{$cover_photo_id}/picture?access_token={$accessToken}' alt=''>";
108 108
     echo "</a>";
109 109
     echo "<p>{$name}</p>";
110 110
 
111
-    $photoCount = ($count > 1)?$count. 'Photos':$count. 'Photo';
111
+    $photoCount = ($count > 1) ? $count . 'Photos' : $count . 'Photo';
112 112
     
113 113
     echo "<p><span style='color:#888;'>{$photoCount} / <a href='{$link}' target='_blank'>View on Facebook</a></span></p>";
114 114
     echo "<p>{$description}</p>";
Please login to merge, or discard this patch.
slideshow.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
     $_SESSION['fb_access_token'] = $accessToken;
24 24
 
25 25
 if(isset($_GET['album_id']) && isset($_GET['album_name'])){
26
-  $album_id =  isset($_GET['album_id'])?$_GET['album_id']:header("Location: fb-callback.php");
27
-  $album_name = $_GET['album_name']; //isset($_GET['album_name'])?:header('Location: fb-callback.php');
26
+    $album_id =  isset($_GET['album_id'])?$_GET['album_id']:header("Location: fb-callback.php");
27
+    $album_name = $_GET['album_name']; //isset($_GET['album_name'])?:header('Location: fb-callback.php');
28 28
 
29 29
 // Get photos of Facebook page album using Facebook Graph API
30 30
 $graphPhoLink = "https://graph.facebook.com/v3.2/{$album_id}/photos?fields=source,images,name&access_token={$accessToken}";
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 echo '</div>';
56 56
 echo '<br/>';
57 57
 echo '<div style="text-align:center">';
58
-  foreach($fbPhotoData as $data){
59
-      echo '<span class="dot"></span>';
58
+    foreach($fbPhotoData as $data){
59
+        echo '<span class="dot"></span>';
60 60
     }
61 61
     echo '</div>';
62 62
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 <?php
9 9
 require_once 'appconfig.php';
10 10
 
11
-if(isset($_SESSION['fb_access_token'])){
11
+if (isset($_SESSION['fb_access_token'])) {
12 12
     // Get access token from session
13
-    $accessToken = (string) $_SESSION['fb_access_token'];
14
-}else{
13
+    $accessToken = (string)$_SESSION['fb_access_token'];
14
+} else {
15 15
     $graphActLink = "https://graph.facebook.com/oauth/access_token?client_id={$appId}&client_secret={$appSecret}&grant_type=client_credentials";
16 16
     
17 17
     // Retrieve access token
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
     // Store access token in session
23 23
     $_SESSION['fb_access_token'] = $accessToken;
24 24
 
25
-if(isset($_GET['album_id']) && isset($_GET['album_name'])){
26
-  $album_id =  isset($_GET['album_id'])?$_GET['album_id']:header("Location: fb-callback.php");
25
+if (isset($_GET['album_id']) && isset($_GET['album_name'])) {
26
+  $album_id = isset($_GET['album_id']) ? $_GET['album_id'] : header("Location: fb-callback.php");
27 27
   $album_name = $_GET['album_name']; //isset($_GET['album_name'])?:header('Location: fb-callback.php');
28 28
 
29 29
 // Get photos of Facebook page album using Facebook Graph API
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 echo '<div class="slideshow-container">';
40 40
 
41 41
 // Render all photos
42
-if (is_array($fbPhotoData) || is_object($fbPhotoData) && $fbPhotoData!=null)
42
+if (is_array($fbPhotoData) || is_object($fbPhotoData) && $fbPhotoData != null)
43 43
     {
44
-foreach($fbPhotoData as $data){
44
+foreach ($fbPhotoData as $data) {
45 45
     $imageData = end($data['images']);
46
-    $imgSource = isset($imageData['source'])?$imageData['source']:'';
47
-    $name = isset($data['name'])?$data['name']:'';
46
+    $imgSource = isset($imageData['source']) ? $imageData['source'] : '';
47
+    $name = isset($data['name']) ? $data['name'] : '';
48 48
     
49 49
     echo '<div class="mySlides fade">';
50 50
     echo "<img src='{$imgSource}' alt='' style='width:90%;height:80%' />";
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 echo '</div>';
56 56
 echo '<br/>';
57 57
 echo '<div style="text-align:center">';
58
-  foreach($fbPhotoData as $data){
58
+  foreach ($fbPhotoData as $data) {
59 59
       echo '<span class="dot"></span>';
60 60
     }
61 61
     echo '</div>';
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 if(isset($_SESSION['fb_access_token'])){
12 12
     // Get access token from session
13 13
     $accessToken = (string) $_SESSION['fb_access_token'];
14
-}else{
14
+} else{
15 15
     $graphActLink = "https://graph.facebook.com/oauth/access_token?client_id={$appId}&client_secret={$appSecret}&grant_type=client_credentials";
16 16
     
17 17
     // Retrieve access token
Please login to merge, or discard this patch.