0
Hello. I need to pick up several Instagram posts and for that I made a simple classes using CURL to pick up Json from Instagram. For this I used a token and a normal userid. When the first request is made within the while block, it returns the json with the most recent post and within that json a property called next_url which in theory is a pagination for the next recent post. Well by executing the code below he can get this the next_url a few times until he gets to the last one, but he does it by skipping several more recent dates. Think like this days 11/03/15 had the last post, in the second execution it goes to 27/02/15, in the third to 09/02/15 and in the fourth to 02/12/14. What might be? logic error, or problems with the API.
while ($api != false) {
if ($count == $limite) {
break;
}
$response = json_decode($this->getUrl($api));
$this->posts[$this->post_count] = array("type" => "it");
$this->posts[$this->post_count]["imgcont"] = "yes";
$this->posts[$this->post_count]["imagem"] = $response->data[0]->images->standard_resolution->url;
$this->posts[$this->post_count]["texto"] = isset($response->data[0]->caption->text) ? $response->data[0]->caption->text : '';
$this->posts[$this->post_count]["postdate"] = $this->dateToString($this->stampToDate($response->data[0]->created_time));
$this->posts[$this->post_count]["elapsed"] = $this->getDays($response->data[0]->created_time, false);
$this->posts[$this->post_count]["link"] = $response->data[0]->link;
$this->post_count++;
$count++;
$api = false;
if (property_exists($response, "pagination")) {
if (property_exists($response->pagination, "next_url")) {
$api = $response->pagination->next_url;
}
}
}