I added getNextPage() to Response object
Closed this issue · 5 comments
I thought you might be interested in some simple functionality I added to the Symfony version of Instaphp
ollietb/OhInstagramBundle@95aca8b
Can be used like this:
$response = $this->api->Tags->Recent($tag, $options);
do {
$pages[] = $response->data;
} while($response = $response->getNextPage());
It will get every page of results and put each into the $pages array
@ollietb Hey, thanks!! Do you can tell me how i can implement your new lines to sesser´s basic code?
Thanks for your answer!
Greetings!
@drosa88 that code refers to an old version. Instaphp has been rewritten since. I need to remove that from the readme.
@ollietb yea, i´ve found the function getNextPage() on one of the Instaphp files:
public function getNextPage()
{
if(property_exists($this, 'pagination'))
{
$pagination = $this->pagination;
if(is_object($pagination) && property_exists($pagination, 'next_url'))
{
$nextUrl = $this->pagination->next_url;
if($nextUrl) {
// take out the query parameters and put them into an array
$urlInfo = parse_url($nextUrl);
parse_str($urlInfo['query'], $params);
//get the new Response
$result = $this->request->Get(strstr($nextUrl, '?', true), $params);
return $result->response;
}
}
}
return false;
}
But i don´t know how i can use this in my project, i can´t find examples.. my foreach loop:
foreach ($dd_user_recent_media->data as $item) {
if ( ( $titan->getOption( 'layout' ) == 1 ) || ( $titan->getOption( 'layout' ) == 2 ) ) {
printf("
<li class='$dd_li_class'>
<a target='$output_target' href='$output_href' $output_attr_lb>
<img alt='$image_username' src='%s'/>
$output_hover_layer
</a>
</li>
", $image_high_res);
}
} //End Foreach
Any idea? :-)
@drosa88 you can read about pagination in the instagram docs https://instagram.com/developer/endpoints/
out of date