Why does Instagram's pagination return the same page over and over? Why does Instagram's pagination return the same page over and over? wordpress wordpress

Why does Instagram's pagination return the same page over and over?


In your first snippet of code you have:

    $this->data["response"] = $response["data"];    $this->data["next_page"] = $response["pagination"]["next_url"];

Note two keys: response and next_page

Then in your second snippet you have:

    $this->data["pagination"] = $response["pagination"]["next_url"];    $this->data["response"] = $response["data"];

Now next_page is pagination

Now if you use

$this->api_request( $this->data["pagination"] );

But you are using $this->data["next_page"] = $response["pagination"]["next_url"]; of course you will not get the right results.

In any case try to var_dump the content of of your $request:

public function pagination_query() {    var_dump($this->data["pagination"]);    $this->api_request( $this->data["pagination"] );    $output = json_encode( $this->data["photos"] );    return $output;}

If you have a debbugger also check inside api_request which is the url passed each time


I've added the following lines of code to the try block of my try...catch statement to return several successive pages at a time:

while ( count( $this->data["photos"] ) < 160 ) {    $this-> api_request( $this->data["next_page"] );}

This essentially tells api_request to call itself until my $this->data["next_page"] array is populated with 160 "grams."

This allows me retrieve a total of 320 grams from Instagram's api: 160 grams when api_request is called after page load and another 160 from my first pagination_query call.

This isn't an ideal solution as a second pagination_query call still returns the same data from my first pagination_query call but it will have to do for the time being.

Update

The above solution is a hack. If anyone can figure out why my pagination_query method still isn't working, it would be much appreciated.