Passed
Push — master ( 87a9ab...35ab17 )
by Rakesh
01:43
created

slideshow.php (1 issue)

Labels
Severity
1
<html>
2
<head>
3
<meta name="viewport" content="width=device-width, initial-scale=1">
4
<title>Slide Show of Album</title>
5
<link rel="stylesheet" type="text/css" href="lib/CSS/slider.css">
6
</head>
7
<body>
8
<?php
9
require_once 'appconfig.php';
10
11
if(isset($_SESSION['fb_access_token'])){
12
    // Get access token from session
13
    $accessToken = (string) $_SESSION['fb_access_token'];
14
}else{
15
    $graphActLink = "https://graph.facebook.com/oauth/access_token?client_id={$appId}&client_secret={$appSecret}&grant_type=client_credentials";
16
    
17
    // Retrieve access token
18
    $accessTokenJson = file_get_contents($graphActLink);
19
    $accessTokenObj = json_decode($accessTokenJson);
20
    $accessToken = $accessTokenObj->access_token;
21
    
22
    // Store access token in session
23
    $_SESSION['fb_access_token'] = $accessToken;
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");
0 ignored issues
show
Are you sure the usage of header('Location: fb-callback.php') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
27
  $album_name = $_GET['album_name']; //isset($_GET['album_name'])?:header('Location: fb-callback.php');
28
29
// Get photos of Facebook page album using Facebook Graph API
30
$graphPhoLink = "https://graph.facebook.com/v3.2/{$album_id}/photos?fields=source,images,name&access_token={$accessToken}";
31
$jsonData = file_get_contents($graphPhoLink);
32
$fbPhotoObj = json_decode($jsonData, true, 512, JSON_BIGINT_AS_STRING);
33
34
// Facebook photos content
35
$fbPhotoData = $fbPhotoObj['data'];
36
37
echo "<h2>" . $album_name . "</h2>";
38
39
echo '<div class="slideshow-container">';
40
41
// Render all photos
42
if (is_array($fbPhotoData) || is_object($fbPhotoData) && $fbPhotoData!=null)
43
    {
44
foreach($fbPhotoData as $data){
45
    $imageData = end($data['images']);
46
    $imgSource = isset($imageData['source'])?$imageData['source']:'';
47
    $name = isset($data['name'])?$data['name']:'';
48
    
49
    echo '<div class="mySlides fade">';
50
    echo "<img src='{$imgSource}' alt='' style='width:90%;height:80%' />";
51
    echo '<div class="text">' . $name . '</div>';
52
    echo '</div>';
53
}
54
55
echo '</div>';
56
echo '<br/>';
57
echo '<div style="text-align:center">';
58
  foreach($fbPhotoData as $data){
59
      echo '<span class="dot"></span>';
60
    }
61
    echo '</div>';
62
}
63
}
64
}
65
?>
66
<script type="text/javascript" src="lib/JavaScript/slider.js"></script>
67
</body>
68
</html>