This a working example based on the previous posted workflow.
Feedback is as always welcome.
Original project repository: Instagram-PHP-API
The index file contains the Javascript which is responsible for loading new data and a bit of PHP which displays the first results. The script makes use of jQuery's DOM data storage, to store the latest max_id
.
This file represents the API which delivers additional images via pagination
.
It requires two GET
parameters:
tag
the tag name you used in your original request (index.php file)max_id
next max id
and returns a JSON object e.g.:
{
next_id: 1340220451361,
images: [
"http://distilleryimage7.s3.amazonaws.com/d53ffb38bafa11e181bd12313817987b_5.jpg",
"http://distilleryimage8.s3.amazonaws.com/647011aebaff11e188131231381b5c25_5.jpg",
"http://distilleryimage2.s3.amazonaws.com/7206772cbaff11e1b9f1123138140926_5.jpg",
...
]
}
Example AJAX call:
http://example.com/ajax.php?tag=kitty&max_id=1340220451361
Copyright (c) 2011-2012 - Programmed by Christian Metz
Released under the BSD License.
this code was not working at first
but then i replaced
In ajax.php:
$media = $instagram->getTagMedia('your_tag',$auth=false,array('max_tag_id'=>$maxID));
in instagram.class.php:
public function getTagMedia($name, $auth=false, $params=null) {
return $this->_makeCall('tags/' . $name . '/media/recent', $auth, $params);
}
as @isratmir mentioned below and i started to get 1 (same) image all the time.
later one and after checking each line i figured out the problem... (didnt see it at first)
change in this line (your_tag) to an actual tag
$media = $instagram->getTagMedia('your_tag',$auth=false,array('max_tag_id'=>$maxID));
and voila problem solved and i started to get 20 new images per request