<?php
/**
* by Nicolae Vartolomei <me@nvartolomei.com>
*
* Flickr crowler.
*/
set_time_limit(0);
ignore_user_abort(TRUE);
require_once "config.php";
require_once LIB_DIR . "/phpFlickr.php";
$flickr = new phpFlickr(API_KEY, API_SECRET);
$userCount = count($users);
for ($i = 0; $i < $userCount; $i++) {
$photos = $flickr->people_getPublicPhotos($users[$i]["flickrId"]);
$totalViews = 0;
foreach($photos['photos']['photo'] as $photo) {
$info = $flickr->photos_getInfo($photo['id']);
$totalViews += $info['views'];
}
$users[$i]["views"] = $totalViews;
}
$temp = count(file($dumpFile));
$handle = fopen($dumpFile, "a");
$toWrite = $temp . ";";
for ($i = 0; $i < $userCount; $i++) {
$toWrite .= $users[$i]["views"];
if ($i < $userCount - 1) {
$toWrite .= ";";
}
}
$toWrite .= "\n";
fwrite($handle, $toWrite);