0

i'm using this api:

public function getUserMedia($id = 'self', $limit = 0) {
  return $this->_makeCall('users/'.$id.'/media/recent', true, array('count' => $limit));
}

to fetch the photo of a user logged in my site using php

it works, and all other api works.

the problem is that i want to retrieve ALL the photo of a user (such as printstagr.am). i've searched in the api but without success: it seems that you can take the recents or the populars, but the site mentioned above takes all. any idea? thanks!

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
D Ferra
  • 1,223
  • 3
  • 12
  • 21
  • Follow this answer work for me http://stackoverflow.com/questions/14414606/getting-basic-information-from-instagram-using-php/31812442#31812442 – Wasim A. Aug 04 '15 at 14:49

1 Answers1

1

Not sure what the max count is (saw someone mention 20 was the max on another question, but can't find any limit in the docs from a quick scan), but essentially what you have to do is request as many as possible, then follow the pagination links to collect more.

So from the api docs they provide this:

{
    ...
    "pagination": {
        "next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
        "next_max_id": "13872296"
    }
}

Your application needs to store the objects from the request (i.e. an array), then fire a new request to the "next_url", put those objects into the same store (i.e. array), then follow the link again, until you reach the end or until you get enough to satisfy your needs.

Lee
  • 10,496
  • 4
  • 37
  • 45
  • Yes, you are absolutely right, the max count is 20, you need to keep on requesting the next url.. – Niket Malik Feb 03 '14 at 17:05
  • i've solved it simply modifing the code from getUserMedia($id = 'self', $limit = 0) to getUserMedia($id = 'self', $limit = -1) – D Ferra Feb 06 '14 at 13:04