Passed
Push — master ( 87a9ab...35ab17 )
by Rakesh
01:43
created
fb-callback.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -10,37 +10,37 @@  discard block
 block discarded – undo
10 10
 require_once 'appconfig.php';
11 11
 
12 12
 $fb = new Facebook\Facebook([
13
-  'app_id' => $appId, // variable with My Facebook App ID
14
-  'app_secret' => $appSecret,
15
-  'default_graph_version' => 'v3.2',
16
-  ]);
13
+    'app_id' => $appId, // variable with My Facebook App ID
14
+    'app_secret' => $appSecret,
15
+    'default_graph_version' => 'v3.2',
16
+    ]);
17 17
 $helper = $fb->getRedirectLoginHelper();
18 18
 if(isset($_GET['state'])){
19
-  $helper->getPersistentDataHandler()->set('state',$_GET['state']);
19
+    $helper->getPersistentDataHandler()->set('state',$_GET['state']);
20 20
 }
21 21
 try {
22
-  $accessToken = $helper->getAccessToken();
22
+    $accessToken = $helper->getAccessToken();
23 23
 } catch(Facebook\Exceptions\FacebookResponseException $e) {
24
-  // When Graph returns an error
25
-  echo 'Graph returned an error: ' . $e->getMessage();
26
-  exit;
24
+    // When Graph returns an error
25
+    echo 'Graph returned an error: ' . $e->getMessage();
26
+    exit;
27 27
 } catch(Facebook\Exceptions\FacebookSDKException $e) {
28
-  // When validation fails or other local issues
29
-  echo 'Facebook SDK returned an error: ' . $e->getMessage();
30
-  exit;
28
+    // When validation fails or other local issues
29
+    echo 'Facebook SDK returned an error: ' . $e->getMessage();
30
+    exit;
31 31
 }
32 32
 if (!isset($accessToken)) {
33
-  if ($helper->getError()) {
33
+    if ($helper->getError()) {
34 34
     header('HTTP/1.0 401 Unauthorized');
35 35
     echo "Error: " . $helper->getError() . "\n";
36 36
     echo "Error Code: " . $helper->getErrorCode() . "\n";
37 37
     echo "Error Reason: " . $helper->getErrorReason() . "\n";
38 38
     echo "Error Description: " . $helper->getErrorDescription() . "\n";
39
-  } else {
39
+    } else {
40 40
     header('HTTP/1.0 400 Bad Request');
41 41
     echo 'Bad request hihihih';
42
-  }
43
-  exit;
42
+    }
43
+    exit;
44 44
 }
45 45
 // Logged in
46 46
 echo '<h3>Access Token</h3>';
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
 //$tokenMetadata->validateUserId('123');
58 58
 $tokenMetadata->validateExpiration();
59 59
 if (! $accessToken->isLongLived()) {
60
-  // Exchanges a short-lived access token for a long-lived one
61
-  try {
60
+    // Exchanges a short-lived access token for a long-lived one
61
+    try {
62 62
     $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
63
-  } catch (Facebook\Exceptions\FacebookSDKException $e) {
63
+    } catch (Facebook\Exceptions\FacebookSDKException $e) {
64 64
     echo "<p>Error getting long-lived access token: " . $e->getMessage() . "</p>\n\n";
65 65
     exit;
66
-  }
67
-  echo '<h3>Long-lived</h3>';
68
-  var_dump($accessToken->getValue());
66
+    }
67
+    echo '<h3>Long-lived</h3>';
68
+    var_dump($accessToken->getValue());
69 69
 }
70 70
 
71 71
 $_SESSION['fb_access_token'] = (string) $accessToken;
Please login to merge, or discard this patch.
slideshow.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@  discard block
 block discarded – undo
6 6
 </head>
7 7
 <body>
8 8
 <?php
9
-  session_start();
9
+    session_start();
10 10
 require_once 'appconfig.php';
11 11
 require_once 'fb-callback.php';
12 12
 
13 13
 if(isset($_SESSION['fb_access_token'])){
14 14
 
15
-  $accessToken = (string) $_SESSION['fb_access_token'];
15
+    $accessToken = (string) $_SESSION['fb_access_token'];
16 16
 }
17
-  $graphActLink = "https://graph.facebook.com/oauth/access_token?client_id={$appId}&client_secret={$appSecret}&grant_type=client_credentials";
17
+    $graphActLink = "https://graph.facebook.com/oauth/access_token?client_id={$appId}&client_secret={$appSecret}&grant_type=client_credentials";
18 18
     // Retrieve access token
19 19
     $accessTokenJson = file_get_contents($graphActLink);
20 20
     $accessTokenObj = json_decode($accessTokenJson);
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
     $_SESSION['fb_access_token'] = $accessToken;
25 25
 
26 26
 if(isset($_GET['album_id']) && isset($_GET['album_name'])){
27
-  $album_id =  $_GET['album_id'];
28
-  $album_name = $_GET['album_name'];
27
+    $album_id =  $_GET['album_id'];
28
+    $album_name = $_GET['album_name'];
29 29
 
30 30
 // Get photos of Facebook page album using Facebook Graph API
31 31
 $graphPhoLink = "https://graph.facebook.com/v3.2/{$album_id}/photos?fields=source,images,name&access_token={$accessToken}";
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 echo '</div>';
58 58
 echo '<br/>';
59 59
 echo '<div style="text-align:center">';
60
-  foreach($fbPhotoData as $data){
61
-      echo '<span class="dot"></span>';
60
+    foreach($fbPhotoData as $data){
61
+        echo '<span class="dot"></span>';
62 62
     }
63 63
     echo '</div>';
64 64
 }else{
65
-  echo "We care for your privacy. Only public photos will be displayed !";
65
+    echo "We care for your privacy. Only public photos will be displayed !";
66 66
 }
67 67
 }
68 68
 //}
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 session_start();
3
-  require_once 'appconfig.php';
3
+    require_once 'appconfig.php';
4 4
 
5
-  $fb = new Facebook\Facebook([
5
+    $fb = new Facebook\Facebook([
6 6
     'app_id' => $appId,
7 7
     'app_secret' => $appSecret,
8 8
     'default_graph_version' => 'v3.2',
9 9
     ]);
10 10
   
11
-  $helper = $fb->getRedirectLoginHelper();
11
+    $helper = $fb->getRedirectLoginHelper();
12 12
   
13
-  $permissions = ['email','user_photos','user_videos','user_posts','user_link','user_status','user_link']; // Optional permissions
14
-  $loginUrl = $helper->getLoginUrl($CallbackUrl,$permissions);
13
+    $permissions = ['email','user_photos','user_videos','user_posts','user_link','user_status','user_link']; // Optional permissions
14
+    $loginUrl = $helper->getLoginUrl($CallbackUrl,$permissions);
15 15
   
16
-  echo "<h3> Connect Clicking Below Facebook Icon Using Your Facebook Account.<h3>";
17
-  echo '<a href="' .htmlspecialchars($loginUrl).'"><img alt="Login With Facebook" src="images/fb_icon.png"></a>';
18 16
\ No newline at end of file
17
+    echo "<h3> Connect Clicking Below Facebook Icon Using Your Facebook Account.<h3>";
18
+    echo '<a href="' .htmlspecialchars($loginUrl).'"><img alt="Login With Facebook" src="images/fb_icon.png"></a>';
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
member.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,57 +12,57 @@
 block discarded – undo
12 12
     try {
13 13
         // Returns a `Facebook\FacebookResponse` object
14 14
         $response = $fb->get('/me?fields=id,name', $accessToken);
15
-      } catch(Facebook\Exceptions\FacebookResponseException $e) {
15
+        } catch(Facebook\Exceptions\FacebookResponseException $e) {
16 16
         echo 'Graph returned an error: ' . $e->getMessage();
17 17
         exit;
18
-      } catch(Facebook\Exceptions\FacebookSDKException $e) {
18
+        } catch(Facebook\Exceptions\FacebookSDKException $e) {
19 19
         echo 'Facebook SDK returned an error: ' . $e->getMessage();
20 20
         exit;
21
-      }
22
-      $user = $response->getGraphUser();
21
+        }
22
+        $user = $response->getGraphUser();
23 23
       
24
-      //echo 'ID: ' . $user['id'] ;
25
-      echo '<br/ >Welcome, ' . $user['name'];
26
-      echo '<a href="logout.php" > Logout </a>';
24
+        //echo 'ID: ' . $user['id'] ;
25
+        echo '<br/ >Welcome, ' . $user['name'];
26
+        echo '<a href="logout.php" > Logout </a>';
27 27
       
28
-      // Get photo albums of Facebook page using Facebook Graph API
29
-      $fields = "id,name,description,link,cover_photo,count,images";
30
-      $userid = $user['id'];
28
+        // Get photo albums of Facebook page using Facebook Graph API
29
+        $fields = "id,name,description,link,cover_photo,count,images";
30
+        $userid = $user['id'];
31 31
       
32
-      $graphAlbLink = "https://graph.facebook.com/v3.2/{$userid}/albums?fields={$fields}&access_token={$accessToken}";
33
-      $jsonData = file_get_contents($graphAlbLink);
34
-      $fbAlbumObj = json_decode($jsonData, true, 512, JSON_BIGINT_AS_STRING);
32
+        $graphAlbLink = "https://graph.facebook.com/v3.2/{$userid}/albums?fields={$fields}&access_token={$accessToken}";
33
+        $jsonData = file_get_contents($graphAlbLink);
34
+        $fbAlbumObj = json_decode($jsonData, true, 512, JSON_BIGINT_AS_STRING);
35 35
       
36
-      // Facebook albums content
37
-      $fbAlbumData = $fbAlbumObj['data'];
36
+        // Facebook albums content
37
+        $fbAlbumData = $fbAlbumObj['data'];
38 38
       
39
-      // Render all photo albums
40
-      echo "<br/><br/>";
41
-      foreach($fbAlbumData as $data){
42
-          $id = isset($data['id'])?$data['id']:'';
43
-          $name = isset($data['name'])?$data['name']:'';
44
-          $description = isset($data['description'])?$data['description']:'';
45
-          $link = isset($data['link'])?$data['link']:'';
46
-          $photos = "https://graph.facebook.com/v3.2/{$id}/photos?access_token={$accessToken}";
47
-          $cover_photo_id = isset($data['cover_photo']['id'])?$data['cover_photo']['id']:'';
48
-          $count = isset($data['count'])?$data['count']:'';
39
+        // Render all photo albums
40
+        echo "<br/><br/>";
41
+        foreach($fbAlbumData as $data){
42
+            $id = isset($data['id'])?$data['id']:'';
43
+            $name = isset($data['name'])?$data['name']:'';
44
+            $description = isset($data['description'])?$data['description']:'';
45
+            $link = isset($data['link'])?$data['link']:'';
46
+            $photos = "https://graph.facebook.com/v3.2/{$id}/photos?access_token={$accessToken}";
47
+            $cover_photo_id = isset($data['cover_photo']['id'])?$data['cover_photo']['id']:'';
48
+            $count = isset($data['count'])?$data['count']:'';
49 49
           
50
-          $pictureLink = "slideshow.php?album_id={$id}&album_name={$name}";
51
-          echo "<div class='carding'>";
52
-          echo "<a href='{$pictureLink}'>";
53
-          $cover_photo_id = (!empty($cover_photo_id))?$cover_photo_id : 123456;
54
-          echo "<img width=200px height=200px src='https://graph.facebook.com/v3.2/{$cover_photo_id}/picture?access_token={$accessToken}' alt=''>";
55
-          echo "<p>{$name}</p>";
56
-          echo "</a>";
57
-          //echo "$images";
58
-          echo "<a href='{$photos}'> <button type='button'> Download Album </Button> </a>";
50
+            $pictureLink = "slideshow.php?album_id={$id}&album_name={$name}";
51
+            echo "<div class='carding'>";
52
+            echo "<a href='{$pictureLink}'>";
53
+            $cover_photo_id = (!empty($cover_photo_id))?$cover_photo_id : 123456;
54
+            echo "<img width=200px height=200px src='https://graph.facebook.com/v3.2/{$cover_photo_id}/picture?access_token={$accessToken}' alt=''>";
55
+            echo "<p>{$name}</p>";
56
+            echo "</a>";
57
+            //echo "$images";
58
+            echo "<a href='{$photos}'> <button type='button'> Download Album </Button> </a>";
59 59
       
60
-          $photoCount = ($count > 1)?$count. 'Photos':$count. 'Photo';
60
+            $photoCount = ($count > 1)?$count. 'Photos':$count. 'Photo';
61 61
           
62
-          echo "<p><span style='color:#888;'>{$photoCount} / <a href='{$link}' target='_blank'>View on Facebook</a></span></p>";
63
-          echo "<p>{$description}</p>";
64
-          echo "</div>";
65
-      }
62
+            echo "<p><span style='color:#888;'>{$photoCount} / <a href='{$link}' target='_blank'>View on Facebook</a></span></p>";
63
+            echo "<p>{$description}</p>";
64
+            echo "</div>";
65
+        }
66 66
 }else{
67 67
     header('Location: index.php');
68 68
 }
Please login to merge, or discard this patch.