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