I need the feed to provide seven images at a time. For some reason, all pages provide seven except the first page which only provides 5.
<?php
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$maxtagid = (isset($_GET['instatag'])) ? $_GET['instatag'] : false;
$url = "https://api.instagram.com/v1/users/self/feed?access_token=$accesstoken&count=7";
if($maxtagid){
$url .= "&max_id=$maxtagid";
}
$result = json_decode(fetchData($url));
foreach ($result->data as $post) echo '<div class="insta-square"><a target="_blank" href="'.$post->link.'"><img src="'.$post->images->standard_resolution->url.'" alt="'.$post->caption->text.'" width="100%" height="auto" /></a></div>';
$nextmax = $result->pagination->next_max_id;
if($nextmax != ''){ ?>
<div class="insta-square"><a href="<?php echo get_home_url(); ?>/gallery?instatag=<?php echo $nextmax; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/next-slide-square.png" /></a></div>
<?php } ?>
I have played around with all kinds of settings, if $maxtagid is set, removing the VERIFYPEER, etc. and nothing seems to work. What am I doing wrong?