Created
April 8, 2010 18:13
-
-
Save jcleblanc/360346 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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