Last active
August 29, 2015 13:59
Revisions
-
planetguru revised this gist
Apr 15, 2014 . 1 changed file with 8 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ <?php // download all flickr images from a given userid // userid is embedded in this url $key = "enterkeyhere"; $url = "https://api.flickr.com/services/rest/?method=flickr.people.getPhotos&api_key=".$key."&user_id=120759744%40N07&per_page=80&page="; $append = "&format=json&nojsoncallback=1"; for($i=1; $i<4; $i++){ // 3 pages of 80 images $uri = $url.$i.$append; $ch = curl_init(); @@ -15,19 +15,20 @@ for($i=0; $i<10; $i++){ $result=curl_exec($ch); $stuff = json_decode($result,true); date_default_timezone_set("Europe/London"); foreach($stuff['photos']['photo'] as &$photo){ // image url is http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg $farmid= $photo['farm']; $serverid= $photo['server']; $id= $photo['id']; $secret= $photo['secret']; $title= $photo['title']; $timestamp = strtotime($title); printf("\n%s",$timestamp); $imageurl = "http://farm".$farmid.".staticflickr.com/".$serverid."/".$id."_".$secret."_b.jpg"; printf("\n%s",$imageurl); $output = '/tmp/flickrcam/'.$timestamp.'.jpg'; file_put_contents($output, file_get_contents($imageurl)); } } -
planetguru created this gist
Apr 15, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ <?php // download all flickr images from a given userid $key = "asdf"; // userid is embedded in this url $url = "https://api.flickr.com/services/rest/?method=flickr.people.getPhotos&api_key=".$key."&user_id=120759744%40N07&per_page=100&page="; $append = "&format=json&nojsoncallback=1"; for($i=0; $i<10; $i++){ $uri = $url.$i.$append; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL,$uri); $result=curl_exec($ch); $stuff = json_decode($result,true); // get no. photos in total $count=$stuff['photos']['total']; foreach($stuff['photos']['photo'] as &$photo){ // image url is http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg $farmid= $photo['farm']; $serverid= $photo['server']; $id= $photo['id']; $secret= $photo['secret']; $imageurl = "http://farm".$farmid.".staticflickr.com/".$serverid."/".$id."_".$secret."_b.jpg"; printf("\n%s",$imageurl); $output = '/tmp/flickrcam/'.$id.'.jpg'; file_put_contents($output, file_get_contents($imageurl)); } } ?>