Skip to content

Instantly share code, notes, and snippets.

@codepo8
Forked from jcleblanc/yql_flickr_search.php
Created April 9, 2010 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codepo8/361631 to your computer and use it in GitHub Desktop.
Save codepo8/361631 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 = '<ul>';
if (count($photos) > 0){
foreach ($photos as $photo){
$html .= '<li><a href="http://www.flickr.com/photos/'.
$photo['owner'].'/'.$photo['id'].
'"><img src="http://farm'.$photo['farm'].
'.static.flickr.com/'.$photo['server'].
'/'.$photo['id'].'_'.$photo['secret'].
'.jpg" width="75" height="75" alt="'.$photo['title'].
'" /></a></li>';
}
} else {
$html .= 'No Photos Found';
}
$html .= '</ul>';
return $html;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment