function flickr_update()
 {
     $this->load->library('Flickr');
     $this->load->model('flickr_model');
     $flickr = new FlickrAPI();
     $last_update = $this->flickr_model->cronGetLast();
     $page_number = 1;
     $changes = $flickr->getChangesSince($last_update, $page_number);
     if (!empty($changes['photos']['total']) && $changes['photos']['total'] > 0) {
         while ($page_number <= $changes['photos']['pages']) {
             foreach ($changes['photos']['photo'] as $change) {
                 $details = $flickr->getPhotoInfo($change['id']);
                 if (!empty($details['photo'])) {
                     $photo = $details['photo'];
                     $this->flickr_model->addPhoto($photo['id'], $photo['secret'], $photo['server'], $photo['farm'], $photo['license'], $photo['owner']['nsid'], $photo['owner']['realname'], $photo['owner']['username'], $photo['title']['_content'], $photo['description']['_content'], $photo['dates']['posted'], $photo['dates']['taken'], $photo['dates']['lastupdate']);
                     if (!empty($photo['tags']['tag'])) {
                         foreach ($photo['tags']['tag'] as $tag) {
                             $this->flickr_model->tag($photo['id'], $tag['id'], $tag['raw'], $tag['_content']);
                         }
                     }
                 }
             }
             $page_number++;
             if ($page_number <= $changes['photos']['pages']) {
                 $changes = $flickr->getChangesSince($last_update, $page_number);
             }
         }
     }
     $this->flickr_model->cronSetLast();
 }
 function convert_to_dwca($params)
 {
     require_library('FlickrAPI');
     $auth_token = NULL;
     // if(FlickrAPI::valid_auth_token(FLICKR_AUTH_TOKEN)) $auth_token = FLICKR_AUTH_TOKEN;
     $page = 1;
     $per_page = 500;
     $url = $this->service['photosets'] . '&photoset_id=' . $params['photoset_id'] . '&user_id=' . $params['flickr_user_id'] . '&per_page=' . $per_page;
     if ($json = Functions::lookup_with_cache($url . '&page=' . $page, $this->download_options)) {
         $json = str_replace("\\'", "'", $json);
         $obj = json_decode($json);
         $total_pages = ceil($obj->photoset->total / $per_page);
         echo "\ntotal_pages = {$total_pages}\n";
         for ($i = 1; $i <= $total_pages; $i++) {
             if ($json = Functions::lookup_with_cache($url . '&page=' . $page, $this->download_options)) {
                 $json = str_replace("\\'", "'", $json);
                 $obj = json_decode($json);
                 $k = 0;
                 $total_photos = count($obj->photoset->photo);
                 foreach ($obj->photoset->photo as $rec) {
                     $k++;
                     echo "\n{$i} of {$total_pages} - {$k} of {$total_photos}";
                     if (!($sciname = self::get_sciname_from_title($rec->title))) {
                         continue;
                     }
                     // if($sciname == "SONY DSC") //debug
                     // {
                     //     print_r($rec);
                     // }
                     $photo_response = FlickrAPI::photos_get_info($rec->id, $rec->secret, $auth_token, $this->download_options);
                     $photo = @$photo_response->photo;
                     if (!$photo) {
                         continue;
                     }
                     if ($photo->visibility->ispublic != 1) {
                         continue;
                     }
                     if ($photo->usage->candownload != 1) {
                         continue;
                     }
                     if (@(!$GLOBALS["flickr_licenses"][$photo->license])) {
                         continue;
                     }
                     $data_objects = FlickrAPI::get_data_objects($photo, $params['flickr_user_id']);
                     foreach ($data_objects as $do) {
                         self::create_archive($sciname, $do);
                     }
                 }
             }
             $page++;
             // break; //debug
         }
     }
     $this->archive_builder->finalize(TRUE);
 }
Example #3
0
<?php

define('FLICKR_API_KEY', 'YOUR API KEY');
include './FlickrAPI.class.php';
$flickr = new FlickrAPI(FLICKR_API_KEY);
$result = null;
if (isset($_REQUEST['action'])) {
    switch ($_REQUEST['action']) {
        case 'getPhotosetList':
            $result = $flickr->getPhotosetList($_REQUEST['user_id']);
            break;
        case 'getPhotosetPhotos':
            $result = $flickr->getPhotosetPhotos($_REQUEST['photoset_id']);
            break;
    }
}
$response = json_encode($result);
header('Content-Type: application/json');
header('Content-Length: ' . strlen($response));
echo $response;
exit;
Example #4
0
// .3 seconds wait time
include_once dirname(__FILE__) . "/../../config/environment.php";
$resource_id = 15;
if (!Functions::can_this_connector_run($resource_id)) {
    return;
}
require_library('FlickrAPI');
$GLOBALS['ENV_DEBUG'] = false;
$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
FlickrAPI::get_all_eol_photos($auth_token, $resource_file);
// 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");
// set Flickr to force harvest
if (filesize(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml") > 600) {
    Functions::set_resource_status_to_force_harvest($resource_id);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Flickr Image Gallery </title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

<?php 
require_once 'flickr_API.php';
$key = '596dcd0930202d1c338ebb17261fae8c';
$Flickr = new FlickrAPI($key);
// get photo ID
$id = isset($_GET['photoid']) ? $_GET['photoid'] : NULL;
$query = isset($_GET['query']) ? $_GET['query'] : NULL;
$page = isset($_GET['page']) ? $_GET['page'] : NULL;
// get photo's information details
$photo = $Flickr->getInfo($id, $secret = NULL);
$photo = $photo['photo'];
//print_r($photo);
//get photo context info
$context = $Flickr->getContext($id);
//print_r($context);
$prev_photo = $context['prevphoto'];
$prev_photo_id = $prev_photo['id'];
$next_photo = $context['nextphoto'];
$next_photo_id = $next_photo['id'];
$photoUrl = $Flickr->getPhotoURL($photo, $size = "large");
//print_r($photoUrl);
Example #6
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";
Example #7
0
<body>
  <div id="header" class="header">
    <form action="main.php" method="get" role="search" class="search_form">
      <input type="search" name="query" id="query" placeholder="Type to search" value="<?php 
echo $_GET['query'];
?>
" required />
      <input type="submit" value="Search" />
   </form>
 </div>

<?php 
require_once 'flickr_API.php';
$key = '596dcd0930202d1c338ebb17261fae8c';
$Flickr = new FlickrAPI($key);
$tags = isset($_GET['query']) ? $_GET['query'] : '';
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$back = $page - 1;
$next = $page + 1;
if (!empty($tags)) {
    //load search returned result page
    $res = $Flickr->search($tags, $page, '5');
} else {
    //load default page with recent uploaded images
    $res = $Flickr->getRecent(NULL, $page);
}
//print_r($res);
// returns total number of pages
$pages = $res['photos']['pages'];
echo "<div class='image_group_wrapper'>";