-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial placeholder script - hard coded values
- Loading branch information
0 parents
commit e929a57
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
run_request(0); | ||
|
||
function build_photos($photos){ | ||
if (count($photos) > 0){ | ||
foreach ($photos->size as $photo){ | ||
$pattern = '/_o\.jpg$/'; | ||
if (preg_match($pattern, $photo->source) > 0){ | ||
system("wget {$photo->source}"); | ||
} | ||
} | ||
} else { | ||
return 'error: no photos found'; | ||
} | ||
return 'photos found'; | ||
} | ||
|
||
function run_request($start){ | ||
$total_photos = 2115; | ||
$yql_url = 'http://query.yahooapis.com/v1/public/yql?'; | ||
$user_id = 'USER_ID'; | ||
$query = "select source from flickr.photos.sizes where photo_id in (select id from flickr.photos.search($start,300) where user_id='$user_id')"; | ||
$query_url = $yql_url . 'q=' . urlencode($query) . '&format=json'; | ||
|
||
$photos = json_decode(file_get_contents($query_url)); | ||
$result = build_photos($photos->query->results); | ||
|
||
$start += 300; | ||
if ($start < $total_photos){ | ||
run_request($start); | ||
} | ||
} | ||
?> |