Skip to content

Instantly share code, notes, and snippets.

@jcleblanc
Created April 8, 2010 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jcleblanc/360346 to your computer and use it in GitHub Desktop.
Save jcleblanc/360346 to your computer and use it in GitHub Desktop.
<?php
$yql_url = 'http://query.yahooapis.com/v1/public/yql?';
$query = 'SELECT * FROM flickr.photos.search WHERE has_geo="true" AND text="san francisco"';
$query_url = $yql_url . 'q=' . urlencode($query) . '&format=xml';
$photos = simplexml_load_file($query_url);
$result = build_photos($photos->results->photo);
echo $result;
function build_photos($photos){
$html = '';
if (count($photos) > 0){
foreach ($photos as $photo){
$html .= "<a href='http://www.flickr.com/photos/{$photo['owner']}/{$photo['id']}' target='_blank'><img src='http://farm4.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}.jpg' width='75' height='75' alt='flickr photo' /></a>";
}
} else {
$html .= 'No Photos Found';
}
return $html;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment