1 | <?php |
||
2 | require_once 'appconfig.php'; |
||
3 | |||
4 | if(isset($_SESSION['fb_access_token'])){ |
||
5 | // Get access token from session |
||
6 | $accessToken = (string) $_SESSION['fb_access_token']; |
||
7 | /* |
||
8 | $fb = new Facebook\Facebook([ |
||
9 | 'app_id' => $appId, |
||
10 | 'app_secret' => $appSecret, |
||
11 | 'default_graph_version' => 'v3.2', |
||
12 | ]); |
||
13 | |||
14 | $helper = $fb->getRedirectLoginHelper(); |
||
15 | |||
16 | if(isset($_GET['state'])){ |
||
17 | $helper->getPersistentDataHandler()->set('state',$_GET['state']); |
||
18 | }*/ |
||
19 | echo $accessToken; |
||
20 | |||
21 | echo 'Welcome, ' . $user['name']; |
||
22 | echo '<a href="logout.php" >Logout</a>'; |
||
23 | |||
24 | // Get photo albums of Facebook page using Facebook Graph API |
||
25 | $fields = "id,name,description,link,cover_photo,count"; |
||
26 | $fb_page_id = $user['id']; |
||
27 | $graphAlbLink = "https://graph.facebook.com/v3.2/{$fb_page_id}/albums?fields={$fields}&access_token={$accessToken}"; |
||
28 | |||
29 | $jsonData = file_get_contents($graphAlbLink); |
||
30 | $fbAlbumObj = json_decode($jsonData, true, 512, JSON_BIGINT_AS_STRING); |
||
31 | |||
32 | // Facebook albums content |
||
33 | $fbAlbumData = $fbAlbumObj['data']; |
||
34 | |||
35 | // Render all photo albums |
||
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']:''; |
||
44 | |||
45 | $pictureLink = "fb-callback.php?album_id={$id}&album_name={$name}"; |
||
46 | |||
47 | |||
48 | echo "<a href='{$pictureLink}'>"; |
||
49 | $cover_photo_id = (!empty($cover_photo_id ))?$cover_photo_id : 123456; |
||
50 | echo "<img width=100px height=100px src='https://graph.facebook.com/v3.2/{$cover_photo_id}/picture?access_token={$accessToken}' alt=''>"; |
||
51 | echo "</a>"; |
||
52 | echo "<p>{$name}</p>"; |
||
53 | |||
54 | $photoCount = ($count > 1)?$count. 'Photos':$count. 'Photo'; |
||
55 | |||
56 | echo "<p><span style='color:#888;'>{$photoCount} / <a href='{$link}' target='_blank'>View on Facebook</a></span></p>"; |
||
57 | echo "<p>{$description}</p>"; |
||
58 | } |
||
59 | //} |
||
60 | |||
61 | $album_id = isset($_GET['album_id'])?$_GET['album_id']:header('Location: fb-callback.php'); |
||
0 ignored issues
–
show
|
|||
62 | $album_name = isset($_GET['album_name'])?$_GET['album_name']: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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
63 | |||
64 | // Get photos of Facebook page album using Facebook Graph API |
||
65 | $graphPhoLink = "https://graph.facebook.com/v3.2/{$album_id}/photos?fields=source,images,name&access_token={$accessToken}"; |
||
66 | $jsonData = file_get_contents($graphPhoLink); |
||
67 | $fbPhotoObj = json_decode($jsonData, true, 512, JSON_BIGINT_AS_STRING); |
||
68 | |||
69 | // Facebook photos content |
||
70 | $fbPhotoData = $fbPhotoObj['data']; |
||
71 | |||
72 | echo "<h2>".$album_name."</h2>"; |
||
73 | |||
74 | // Render all photos |
||
75 | if (is_array($fbPhotoData) || is_object($fbPhotoData)) |
||
76 | { |
||
77 | foreach($fbPhotoData as $data) |
||
78 | { |
||
79 | $imageData = end($data['images']); |
||
80 | $imgSource = isset($imageData['source'])?$imageData['source']:''; |
||
81 | $name = isset($data['name'])?$data['name']:''; |
||
82 | |||
83 | echo "<div class='item'>"; |
||
84 | echo "<img src='{$imgSource}' alt=''>"; |
||
85 | echo "<p>{$name}</p>"; |
||
86 | echo "</div>"; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | |||
91 | echo'</div>'; |
||
92 | |||
93 | echo "<div class='slideshow-container'>"; |
||
94 | |||
95 | // Render all photos |
||
96 | if (is_array($fbPhotoData) || is_object($fbPhotoData)) |
||
97 | { |
||
98 | foreach($fbPhotoData as $data){ |
||
99 | $imageData = end($data['images']); |
||
100 | $imgSource = isset($imageData['source'])?$imageData['source']:''; |
||
101 | $name = isset($data['name'])?$data['name']:''; |
||
102 | |||
103 | echo "<div class='mySlides fade'>"; |
||
104 | echo "<img src='{$imgSource}' alt='' style='width:100%'>"; |
||
105 | echo "<div class='text'>{$name}</div>"; |
||
106 | echo "</div>"; |
||
107 | } |
||
108 | } |
||
109 | } |
||
110 | ?> |
||
111 | <br> |
||
112 | |||
113 | <div style="text-align:center"> |
||
114 | <?php |
||
115 | if (is_array($fbPhotoData) || is_object($fbPhotoData)) |
||
116 | { |
||
117 | foreach($fbPhotoData as $data){ |
||
118 | echo "<span class='dot'></span>"; |
||
119 | } |
||
120 | } |
||
121 | ?> |
||
122 | </div> |
||
123 | |||
124 | </div> |
||
125 | |||
126 | |||
127 | <script> |
||
128 | var slideIndex = 0; |
||
129 | showSlides(); |
||
130 | |||
131 | function showSlides() { |
||
132 | var i; |
||
133 | var slides = document.getElementsByClassName("mySlides"); |
||
134 | var dots = document.getElementsByClassName("dot"); |
||
135 | for (i = 0; i < slides.length; i++) { |
||
136 | slides[i].style.display = "none"; |
||
137 | } |
||
138 | slideIndex++; |
||
139 | if (slideIndex > slides.length) {slideIndex = 1} |
||
140 | for (i = 0; i < dots.length; i++) { |
||
141 | dots[i].className = dots[i].className.replace("active", ""); |
||
142 | } |
||
143 | slides[slideIndex-1].style.display = "block"; |
||
144 | dots[slideIndex-1].className += "active"; |
||
145 | setTimeout(showSlides, 2000); // Change image every 2 seconds |
||
146 | } |
||
147 | </script> |
||
148 | |||
149 | <style> |
||
150 | * {box-sizing: border-box;} |
||
151 | body {font-family: Verdana, sans-serif;} |
||
152 | .mySlides {display: none;} |
||
153 | img {vertical-align: middle;} |
||
154 | |||
155 | /* Slideshow container */ |
||
156 | .slideshow-container { |
||
157 | max-width: 1000px; |
||
158 | position: relative; |
||
159 | margin: auto; |
||
160 | } |
||
161 | |||
162 | /* Caption text */ |
||
163 | .text { |
||
164 | color: #f2f2f2; |
||
165 | font-size: 15px; |
||
166 | padding: 8px 12px; |
||
167 | position: absolute; |
||
168 | bottom: 8px; |
||
169 | width: 100%; |
||
170 | text-align: center; |
||
171 | } |
||
172 | |||
173 | /* Number text (1/3 etc) */ |
||
174 | .numbertext { |
||
175 | color: #f2f2f2; |
||
176 | font-size: 12px; |
||
177 | padding: 8px 12px; |
||
178 | position: absolute; |
||
179 | top: 0; |
||
180 | } |
||
181 | |||
182 | /* The dots/bullets/indicators */ |
||
183 | .dot { |
||
184 | height: 15px; |
||
185 | width: 15px; |
||
186 | margin: 0 2px; |
||
187 | background-color: #bbb; |
||
188 | border-radius: 50%; |
||
189 | display: inline-block; |
||
190 | transition: background-color 0.6s ease; |
||
191 | } |
||
192 | |||
193 | .active { |
||
194 | background-color: #717171; |
||
195 | } |
||
196 | |||
197 | /* Fading animation */ |
||
198 | .fade { |
||
199 | -webkit-animation-name: fade; |
||
200 | -webkit-animation-duration: 1.5s; |
||
201 | animation-name: fade; |
||
202 | animation-duration: 1.5s; |
||
203 | } |
||
204 | |||
205 | @-webkit-keyframes fade { |
||
206 | from {opacity: .4} |
||
207 | to {opacity: 1} |
||
208 | } |
||
209 | |||
210 | @keyframes fade { |
||
211 | from {opacity: .4} |
||
212 | to {opacity: 1} |
||
213 | } |
||
214 | |||
215 | /* On smaller screens, decrease text size */ |
||
216 | @media only screen and (max-width: 300px) { |
||
217 | .text {font-size: 11px} |
||
218 | } |
||
219 | </style> |
||
220 | <?php |
||
221 | /*}else{ |
||
222 | header('location:index.php'); |
||
223 | }*/ |
||
224 | ?> |
This check looks for function or method calls that always return null and whose return value is used.
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.