-
Notifications
You must be signed in to change notification settings - Fork 0
/
getallimages.php
27 lines (26 loc) · 1 KB
/
getallimages.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
function getAllImages($albumID, $fb){
$images = "";
$accessToken = $_SESSION['access_token'];
// get 100 images data
$re = $fb->get('/'.$albumID.'?fields=name,photos.limit(100){images}',$accessToken);
$graphEdge = $re->getGraphNode();
// generate string of image source separated by "~"
for($j=0;$j<count($graphEdge['photos']);$j++){
$images .= $graphEdge['photos'][$j]['images'][0]['source']."~";
}
$a = $re->getDecodedBody();
// get next paging url
$str = $a['photos']['paging']['next'];
if($str!=""){
$arr = explode("v3.1",$str);
// get next images
$re = $fb->get($arr[1],$accessToken);
$graphEdge = $re->getGraphEdge();
$images1 = json_decode($graphEdge, true);
foreach($images1 as $img){
$images .=$img['images'][0]['source']."~";
}
}
return $images; // return all images (upto 200)
}