My Apps

Dad's Photo Album

Sample php script

  <?php
    $flickr_key = "[get a flickr api key at http://www.flickr.com/services/api/misc.api_keys.html]";
    $flickr_secret = "[flickr api secret]";

    $fc = unserialize(file_get_contents("http://api.flickr.com/services/rest/?method=flickr.photos.getRecent&api_key=$flickr_key&format=php_serial&extras=date_taken,owner_name&per_page=1"));
    $photos = $fc['photos']['photo'];
    $photo = $photos[rand(0, count($photos)-1)];
    $photo_url = "http://farm${photo['farm']}.static.flickr.com/${photo['server']}/${photo['id']}_${photo['secret']}_b.jpg";
    $tags = $photo['ownername'];
    $date_taken = $photo['datetaken'];

    header('Content-type: image/jpeg');
    header('x-json-docinfo: {"date":"'.$date_taken.'", "tags":"'.$tags.'"}');
    readfile($photo_url);