Flickr API





Example which searches for creative commons licenced images under keyword "attractions"

 * searches for tag "attractions
 * creative commons
 * 300 images - thumbnails
 * creates a div called "attractionbox" so you can format the boxes with the images in css

 <?PHP $api_key = "5aa63a3dc97207bf2af7f2d762560b39"; $tag = 'attractions'; $perPage = '300'; $url = 'http://api.flickr.com/services/rest/?method=flickr.photos.search'; $url.= '&api_key='.$api_key; $url.= '&tags='.$tag; $url.= '&per_page='.$perPage; $url.= '&format=json'; $url.= '&l=deriv'; $url.= '&nojsoncallback=1';

$response = json_decode(file_get_contents($url));

if($response->stat == 'ok') {   $photos = $response->photos->photo; if(count($photos) > 0) {   foreach($photos as $photo) {       $farmId = $photo->farm; $serverId = $photo->server; $id = $photo->id; $secret = $photo->secret; $title = $photo->title; $imagePathThumbnail = 'http://farm'.$farmId.'.static.flickr.com/'.$serverId.'/'.$id.'_'.$secret.'_s.jpg'; $imagePathLarge = 'http://farm'.$farmId.'.static.flickr.com/'.$serverId.'/'.$id.'_'.$secret.'_b.jpg'; $image = ' '; $image.= ''; $image.= ''; $image.= ' '.$title; $image.= ''; $image.= ' '; echo $image; }   }    else {       echo 'No Results'; } } else {   echo ' Error : '.$response->message; } ?> 