示例#1
0
$user_id = "61021753@N02";
// BHL BioDivLibrary's photostream -- http://www.flickr.com/photos/61021753@N02
$start_year = 2010;
$auth_token = NULL;
if (FlickrAPI::valid_auth_token(FLICKR_AUTH_TOKEN)) {
    $auth_token = FLICKR_AUTH_TOKEN;
}
// create new _temp file
if (!($resource_file = Functions::file_open(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_temp.xml", "w+"))) {
    return;
}
// start the resource file with the XML header
fwrite($resource_file, \SchemaDocument::xml_header());
// query Flickr and write results to file
$months_to_be_broken_down = array(0 => array("year" => 2011, "month" => 8), 1 => array("year" => 2011, "month" => 10), 2 => array("year" => 2012, "month" => 8), 3 => array("year" => 2012, "month" => 11), 4 => array("year" => 2013, "month" => 1), 5 => array("year" => 2013, "month" => 3));
FlickrAPI::get_photostream_photos($auth_token, $resource_file, $user_id, $start_year, $months_to_be_broken_down);
// FlickrAPI::get_all_eol_photos($auth_token, $resource_file, $user_id); // old
// write the resource footer
fwrite($resource_file, \SchemaDocument::xml_footer());
fclose($resource_file);
// cache the previous version and make this new version the current version
@unlink(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_previous.xml");
Functions::file_rename(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml", CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_previous.xml");
Functions::file_rename(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_temp.xml", CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml");
Functions::set_resource_status_to_force_harvest($resource_id);
remove_bhl_images_already_existing_in_eol_group($resource_id);
Functions::gzip_resource_xml($resource_id);
$elapsed_time_sec = time_elapsed() - $timestart;
echo "\n";
echo "elapsed time = {$elapsed_time_sec} seconds             \n";
echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes  \n";