I have to use two methods from Flickr to achieve my desired result; "the photos.search method" returns the photo id while the "geo.getLocation method" returns the long and lat value of each photo id. I am able to successfully iterate my search to get each photo id within my search area. My question is how do I iterate each photo id in the "geo.getLocation method" so as to get their latitude and longitude values.
Find below my php code that returns each photo id:
<?php
$url = ("http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ff8c4c178209865b1ac5ee3f2d492de0&lat=51.5424&lon=-0.1734&radius=2&page=1&text=flats");
$xml = simplexml_load_file($url);
foreach ($xml->photos->photo as $entry) {
echo $entry->attributes()->id;
echo $entry->attributes()->owner;
echo $entry->attributes()->title;
}
?>
The REST request format for the geo.getLocation method is:
http://api.flickr.com/services/rest/?method=flickr.photos.geo.getLocation&api_key=xxxx&photo_id=[value]
Yemi
Why not get each location as you iterate over the photo ids, as in
<?php
$url = ("http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ff8c4c178209865b1ac5ee3f2d492de0&lat=51.5424&lon=-0.1734&radius=2&page=1&text=flats");
$xml = simplexml_load_file($url);
foreach ($xml->photos->photo as $entry) {
echo $entry->attributes()->id;
echo $entry->attributes()->owner;
echo $entry->attributes()->title;
$xmlloc = simplexml_load_file("http://api.flickr.com/services/rest/?method=flickr.photos.geo.getLocation&api_key=xxxx&photo_id=" . $entry->attributes()->id);
// process XML file
}
?>