当前位置: 首页>>代码示例>>PHP>>正文


PHP phpFlickr::enableCache方法代码示例

本文整理汇总了PHP中phpFlickr::enableCache方法的典型用法代码示例。如果您正苦于以下问题:PHP phpFlickr::enableCache方法的具体用法?PHP phpFlickr::enableCache怎么用?PHP phpFlickr::enableCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpFlickr的用法示例。


在下文中一共展示了phpFlickr::enableCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ws_images_addFlickr

function ws_images_addFlickr($photo, &$service)
{
    if (!is_admin()) {
        return new PwgError(403, 'Forbidden');
    }
    global $conf;
    if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key'])) {
        return new PwgError(null, l10n('Please fill your API keys on the configuration tab'));
    }
    include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
    include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php';
    include_once FLICKR_PATH . 'include/functions.inc.php';
    if (test_remote_download() === false) {
        return new PwgError(null, l10n('No download method available'));
    }
    // init flickr API
    include_once FLICKR_PATH . 'include/phpFlickr/phpFlickr.php';
    $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']);
    $flickr->enableCache('fs', FLICKR_FS_CACHE);
    // user
    $u = $flickr->test_login();
    if ($u === false or empty($_SESSION['phpFlickr_auth_token'])) {
        return new PwgError(403, l10n('API not authenticated'));
    }
    // photos infos
    $photo_f = $flickr->photos_getInfo($photo['id']);
    $photo = array_merge($photo, $photo_f['photo']);
    $photo['url'] = $flickr->get_biggest_size($photo['id'], 'original');
    $photo['path'] = FLICKR_FS_CACHE . 'flickr-' . $u['username'] . '-' . $photo['id'] . '.' . get_extension($photo['url']);
    // copy file
    if (download_remote_file($photo['url'], $photo['path']) == false) {
        return new PwgError(null, l10n('Can\'t download file'));
    }
    // category
    if (!preg_match('#^[0-9]+$#', $photo['category'])) {
        $categories_names = explode(',', $photo['category']);
        $photo['category'] = array();
        foreach ($categories_names as $category_name) {
            $query = '
SELECT id FROM ' . CATEGORIES_TABLE . '
  WHERE LOWER(name) = "' . strtolower($category_name) . '"
;';
            $result = pwg_query($query);
            if (pwg_db_num_rows($result)) {
                list($cat_id) = pwg_db_fetch_row($result);
                $photo['category'][] = $cat_id;
            } else {
                $cat = create_virtual_category($category_name);
                $photo['category'][] = $cat['id'];
            }
        }
    } else {
        $photo['category'] = array($photo['category']);
    }
    // add photo
    $photo['image_id'] = add_uploaded_file($photo['path'], basename($photo['path']), $photo['category']);
    // do some updates
    if (!empty($photo['fills'])) {
        $photo['fills'] = rtrim($photo['fills'], ',');
        $photo['fills'] = explode(',', $photo['fills']);
        $updates = array();
        if (in_array('fill_name', $photo['fills'])) {
            $updates['name'] = pwg_db_real_escape_string($photo['title']);
        }
        if (in_array('fill_posted', $photo['fills'])) {
            $updates['date_available'] = date('Y-m-d H:i:s', $photo['dates']['posted']);
        }
        if (in_array('fill_taken', $photo['fills'])) {
            $updates['date_creation'] = $photo['dates']['taken'];
        }
        if (in_array('fill_author', $photo['fills'])) {
            $updates['author'] = pwg_db_real_escape_string($photo['owner']['username']);
        }
        if (in_array('fill_description', $photo['fills'])) {
            $updates['comment'] = pwg_db_real_escape_string(@$photo['description']);
        }
        if (in_array('fill_geotag', $photo['fills']) and !empty($photo['location'])) {
            $updates['latitude'] = pwg_db_real_escape_string($photo['location']['latitude']);
            $updates['longitude'] = pwg_db_real_escape_string($photo['location']['longitude']);
        }
        if (in_array('level', $photo['fills']) && !$photo['visibility']['ispublic']) {
            $updates['level'] = 8;
            if ($photo['visibility']['isfamily']) {
                $updates['level'] = 4;
            }
            if ($photo['visibility']['isfriend']) {
                $updates['level'] = 2;
            }
        }
        if (count($updates)) {
            single_update(IMAGES_TABLE, $updates, array('id' => $photo['image_id']));
        }
        if (!empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills'])) {
            $raw_tags = array_map(create_function('$t', 'return $t["_content"];'), $photo['tags']['tag']);
            $raw_tags = implode(',', $raw_tags);
            set_tags(get_tag_ids($raw_tags), $photo['image_id']);
        }
    }
    return l10n('Photo "%s" imported', $photo['title']);
}
开发者ID:biffhero,项目名称:Flickr2Piwigo,代码行数:100,代码来源:ws_functions.inc.php

示例2: phpFlickr

	function __construct($params, $cacheDir = null, $ext = null)
	{
		if (is_null($cacheDir))
		{ 
			$cacheDir = JPATH_ROOT . DS . 'cache';
			if (!is_null($ext))
			{
				$extCacheDir = $cacheDir . DS . $ext;
			
				if (file_exists($extCacheDir) && is_dir($extCacheDir))
					$cacheDir = $extCacheDir;
			}
		}
		
		$this->_cacheDir = $cacheDir;
		$apiKey = $params['apikey'];
		$secretKey = !empty($params['secret']) ? $params['secret'] : null;
		$cachePeriod = @intval($params['cachePeriod'], 10);
		$flickr = new phpFlickr($apiKey, $secretKey);
		
		if (!empty($params['token']))
			$flickr->setToken($params['token']);
		
		if ($cachePeriod > 0 && $this->_cacheDir)
			$flickr->enableCache('fs', $this->_cacheDir, $cachePeriod);

		$this->_flickr =& $flickr;
	}
开发者ID:rkern21,项目名称:videoeditor,代码行数:28,代码来源:class.FlickrProvider.php

示例3: get_images

 /**
  * get images from flickr
  * @author - Henry Addo
  * @access - public 
  * @return - Array of images
  */
 public function get_images()
 {
     $username = "";
     $photo_urls = "http://www.flickr.com/photos/eyedol/";
     $tags = "tedglobal2007";
     // create instance of phpFlickr class
     $flickr = new phpFlickr('');
     //enable caching
     $flickr->enableCache("");
     //authenticate
     //$flickr->auth();
     //get token
     //$token = $token['user']['nsid'];
     // get NSID of the username
     $nsid = $token['user']['nsid'];
     $user = $flickr->people_findByUsername($username);
     //get the friendly URL of the the users' photos
     $photos_url = $flickr->urls_getUserPhotos($username);
     // get 20 images of public images of the user
     //$photos = $flickr->photos_search( array( 'tags'=>$tags,
     //'per_page'=> 200 ) );
     $photos = $flickr->people_getPublicPhotos($username, NULL, 36);
     // loop through the photos
     foreach ((array) $photos['photo'] as $photo) {
         $this->images[] = "<li><a href=\"#\">\n        <img  alt='{$photo['title']}' title='{$photo['title']}'\n        src=\"" . $flickr->buildPhotoURL($photo, 'Square') . "\" \n        onclick=\"get_image_id('" . $flickr->buildPhotoURL($photo) . "','{$photo['title']}')\"/></a></li>";
         $owner = $flickr->people_getInfo($photo[owner]);
         $this->owner = $owner['username'];
     }
     return $this->images;
 }
开发者ID:eyedol,项目名称:flickr_viewer,代码行数:36,代码来源:get_flickr_images.php

示例4: flickrUser

function flickrUser($userName)
{
    global $site;
    $f = new phpFlickr($site["flickr"]["key"]);
    $f->enableCache("fs", $site["path"] . $site["folder"] . $site["flickr"]["cache"], $site["flickr"]["cacheduration"]);
    $user = $f->people_findByUsername($userName);
    return $user;
}
开发者ID:ntctbt,项目名称:LoremFlickr,代码行数:8,代码来源:functions.php

示例5: flickr_stream

function flickr_stream($username, $api_key)
{
    require_once "phpflickr/phpFlickr.php";
    $phpFlickrObj = new phpFlickr($api_key);
    $phpFlickrObj->enableCache("fs", TEMPLATEPATH . "/cache");
    $user = $phpFlickrObj->people_findByUsername($username);
    $user_url = $phpFlickrObj->urls_getUserPhotos($user['id']);
    $photos = $phpFlickrObj->people_getPublicPhotos($user['id'], NULL, NULL, 9);
    foreach ($photos['photos']['photo'] as $photo) {
        echo '<a href="' . $user_url . $photo['id'] . '" title="' . $photo['title'] . ' (on Flickr)" target="_blank">';
        echo '<img style="width: 64px; height: 64px; margin: 1px; padding: 2px; border: 3px solid #ddd; background: #fff;" class="wp-image" alt="' . $photo['title'] . '" src="' . $phpFlickrObj->buildPhotoURL($photo, "square") . '" />';
        echo '</a>';
    }
}
开发者ID:neerajsohal,项目名称:portraiture,代码行数:14,代码来源:helper.php

示例6: display

 function display()
 {
     $flickr = new phpFlickr(ModUtil::getVar('Content', 'flickrApiKey'));
     $flickr->enableCache("fs", System::getVar('temp'));
     // Find the NSID of the username
     $person = $flickr->people_findByUsername($this->userName);
     // Get the photos
     //$photos = $flickr->people_getPublicPhotos($person['id'], NULL, $this->photoCount);
     $photos = $flickr->photos_search(array('user_id' => $person['id'], 'tags' => $this->tags, 'per_page' => $this->photoCount));
     $photoData = array();
     foreach ((array) $photos['photo'] as $photo) {
         $photoData[] = array('title' => DataUtil::formatForDisplayHTML($this->decode($photo['title'])), 'src' => $flickr->buildPhotoURL($photo, "Square"), 'url' => "http://www.flickr.com/photos/{$photo['owner']}/{$photo['id']}");
     }
     $this->view->assign('photos', $photoData);
     return $this->view->fetch($this->getTemplate());
 }
开发者ID:robbrandt,项目名称:Content,代码行数:16,代码来源:Flickr.php

示例7: getFlickrConnection

function getFlickrConnection()
{
    if (FLICKR_KEY) {
        $flickr = new phpFlickr(FLICKR_KEY);
        if (false !== $flickr->test_echo()) {
            $cache = dirname(__FILE__) . '/cache';
            if (file_exists($cache)) {
                $flickr->enableCache("fs", $cache);
            }
            return $flickr;
        } else {
            throw new \RuntimeException('Flickr API Key has been defined but is invalid.');
        }
    } else {
        throw new \RuntimeException('Flickr API Key has not been defined.');
    }
}
开发者ID:ncstate,项目名称:social-sdk,代码行数:17,代码来源:flickr.php

示例8: index

 public function index()
 {
     $this->template->content = new View('flickrwijit_front');
     //fetch flickrwijit settings from db
     $flickrwijit_settings = ORM::factory('flickrwijit', 1);
     // include phpflickr library
     include Kohana::find_file('libraries/phpflickr', 'phpFlickr');
     $f = new phpFlickr(Kohana::config('flickrwijit.flick_api_key'));
     //enable caching
     if ($flickrwijit_settings->enable_cache == 1) {
         $f->enableCache("fs", "application/cache");
     }
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page'), 'total_items' => $flickrwijit_settings->num_of_photos));
     //print_r($pagination);
     $photos = $f->photos_search(array('page' => $pagination->current_page, 'tags' => $flickrwijit_settings->flickr_tag, 'per_page' => (int) Kohana::config('settings.items_per_page'), 'user_id' => $flickrwijit_settings->flickr_id));
     $this->template->content->image_width = $flickrwijit_settings->image_width;
     $this->template->content->image_height = $flickrwijit_settings->image_height;
     $this->template->content->num_of_photos = $flickrwijit_settings->num_of_photos;
     $this->template->content->f = $f;
     $this->template->content->photos = $photos;
     $this->template->content->pagination = $pagination;
 }
开发者ID:eyedol,项目名称:flickrwijit,代码行数:22,代码来源:flickrwijit.php

示例9: phpFlickr

     sharing_display('', true);
 }
 ?>
     <?php 
 get_template_part('partial', 'links');
 ?>
   </div>
   <?php 
 $key = get_field('flickr_key');
 if (!$key) {
     $key = '2926a701327d02571c68efacf6406bf0';
 }
 $username = get_field('flickr_user');
 // $page = isset($_GET['page']) ? $_GET['page'] : 1;
 $f = new phpFlickr($key);
 $f->enableCache('fs', TEMPLATEPATH . '/inc/cache');
 $result = $f->people_findByUsername($username);
 $nsid = $result['id'];
 // $photos = $f->people_getPublicPhotos( $nsid, NULL, NULL, 100, $page );
 $photos = $f->favorites_getPublicList($nsid, NULL, NULL, NULL, NULL, NULL, $page);
 // $pages = $photos[photos][pages];
 // $total = $photos[photos][total];
 ?>
   <div class="content">
     <div class="gallery">
       <?php 
 foreach ($photos['photos']['photo'] as $photo) {
     ?>
       <div class="gallery-item"><a href="<?php 
     echo $f->buildPhotoURL($photo, 'large');
     ?>
开发者ID:rdourado,项目名称:atins.me,代码行数:31,代码来源:template-photos.php

示例10: splitDescription

<?php

//include("phpflickr/auth.php");
//include("phpflickr/example.php");
//include("phpflickr/getToken.php");
include "phpflickr/phpFlickr.php";
$FLICKR_KEY = "SET_VALUE";
$FLICKR_SHARED_SECRET = "SET_VALUE";
$FLICKR_AUTH_TOKEN = "SET_VALUE";
$FLICKR_USER = "SET_VALUE";
$FLICKR = new phpFlickr($FLICKR_KEY, $FLICKR_SHARED_SECRET, true);
$FLICKR->enableCache("fs", "cache");
function splitDescription($details)
{
    return explode("---", $details);
}
function getDescription($split)
{
    return $split[0];
}
function splitDetails($details)
{
    $result = null;
    $split = explode(";", $details[1]);
    foreach ($split as $part) {
        $components = explode(":", $part, 2);
        if (count($components) > 1) {
            $result[trim($components[0])] = trim($components[1]);
        }
    }
    return $result;
开发者ID:NextFaze,项目名称:diy-comic-webviewer,代码行数:31,代码来源:include.php

示例11: phpFlickr

                <img src="http://placehold.it/360x460" />
                </div>
                
                <div id="overview">
				<?php 
        the_content('Read more on "' . the_title('', '', false) . '" &raquo;');
        ?>
    
                </div>

    <?php 
        $flickr_photoset_id = '72157626966312775';
        $flickr_api_key = '2d589541fd6f617409903e97d0e10bbe';
        $flickr_username = 'remodelingappleton';
        $flickr_gallery = new phpFlickr($flickr_api_key);
        $flickr_gallery->enableCache('fs', 'cache');
        $flickr_gallery_people = $flickr_gallery->people_findByUsername($flickr_username);
        $flickr_gallery_user_id = $flickr_gallery_people['id'];
        $flickr_gallery_photos = $flickr_gallery->photosets_getPhotos($flickr_photoset_id, null, null);
        ?>

        <div id="slider" class="flickr-gallery">
        <h2>Interior Design Gallery</h2>
          <div class="infiniteCarousel">
              <div class="wrapper">
                  <ul>
                    <?php 
        foreach ($flickr_gallery_photos['photoset']['photo'] as $photo) {
            ?>
                      <li><a href="<?php 
            echo $flickr_gallery->buildPhotoURL($photo, 'Large');
开发者ID:htmlgraphic,项目名称:Remodeling-Appleton,代码行数:31,代码来源:page-team.php

示例12: getItems

 public function getItems()
 {
     jimport('joomla.filesystem.folder');
     $api_key = '2a4dbf07ad5341b2b06d60c91d44e918';
     $cache_path = JPATH_ROOT . '/cache/test/flickr';
     $nsid = '';
     $photos = array();
     // create cache folder if not exist
     JFolder::create($cache_path, 0755);
     if (!class_exists('phpFlickr')) {
         require_once 'api/phpFlickr.php';
     }
     $f = new phpFlickr($api_key);
     $f->enableCache('fs', $cache_path, $this->get('cache_time'));
     //enable caching
     if ($this->get('flickr_search_from') == 'user') {
         $username = $this->get('flickr_search_from');
         if ($username != NULL) {
             $person = $f->people_findByUsername($username);
             $nsid = $person['id'];
         } else {
             return '';
         }
         $photos = $f->people_getPublicPhotos($nsid, NULL, NULL, $this->get('item_count'));
         $source = $photos['photos']['photo'];
     }
     if ($this->get('flickr_search_from') == 'tags' or $this->get('flickr_search_from') == 'text') {
         $tags = $this->get('flickr_attrs');
         if (!empty($tags)) {
             $attrs = '';
             if ($this->get('flickr_search_from') == 'tags') {
                 $attrs = 'tags';
             }
             if ($this->get('flickr_search_from') == 'text') {
                 $attrs = 'text';
             }
             $photos = $f->photos_search(array($attrs => $tags, 'per_page' => $this->get('item_count')));
             $source = $photos['photo'];
         } else {
             return '';
         }
     }
     if ($this->get('flickr_search_from') == 'recent') {
         $photos = $f->photos_getRecent(NULL, $this->get('item_count'));
         $source = $photos['photo'];
     }
     //$extras = 'description,date_upload,owner_name,tags';
     $items = array();
     $i = 0;
     if (count($source) > 0) {
         foreach ($source as $photo) {
             $id = $photo['id'];
             $obj = new stdClass();
             $info = $f->photos_getInfo($id);
             $nsid = $info['owner']['username'];
             $obj->title = $info['title'];
             $obj->image = $f->buildPhotoURL($photo, '_b');
             $obj->link = $info['urls']['url'][0]['_content'];
             $obj->introtext = $info['description'];
             $obj->date = date('Y.M.d : H:i:s A', $info['dateuploaded']);
             $items[$i] = $obj;
             $i++;
         }
     }
     //return $items;
     var_dump($f);
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:67,代码来源:flickr.php

示例13: phpFlickr

$_youtube_video_height = $params->get('youtube_video_height', '385');
// default 385 pixel
if ($_useFlickr == 1) {
    $_flickr_apikey = $params->get('flickr_apikey', '');
    require_once JPATH_COMPONENT . DS . 'includes/phpflickr/phpFlickr.php';
    $f = new phpFlickr($_flickr_apikey);
    if ($_flickr_cache_mode == 1) {
        $config = new JConfig();
        $_host = $config->host;
        $_db = $config->db;
        $_dbprefix = $config->dbprefix;
        $_user = $config->user;
        $_password = $config->password;
        $_flickr_connect = "mysql://" . $_user . ":" . $_password . "@" . $_host . "/" . $_db;
        $_flickr_cache_table = $_dbprefix . "discussions_flickr_cache";
        $f->enableCache("db", $_flickr_connect, $_flickr_cache_time, $_flickr_cache_table);
    }
}
if ($_imagesDisplayMode == 1) {
    // Slimbox
    $assets = JURI::root() . "components/com_discussions/assets";
    $document->addStyleSheet($assets . '/css/slimbox.css');
}
// website root directory
$_root = JURI::root();
?>


<!-- Javascript functions -->

<?php 
开发者ID:rbista,项目名称:Discussions-J1.6,代码行数:31,代码来源:default.php

示例14: phpFlickr

 *
 * This example file shows you how to call the 100 most recent public
 * photos.  It parses through them and prints out a link to each of them
 * along with the owner's name.
 *
 * Most of the processing time in this file comes from the 100 calls to
 * flickr.people.getInfo.  Enabling caching will help a whole lot with
 * this as there are many people who post multiple photos at once.
 *
 * Obviously, you'll want to replace the "<api key>" with one provided 
 * by Flickr: http://www.flickr.com/services/api/key.gne
 */
require_once "phpFlickr.php";
$f = new phpFlickr("a28fe4e32f1304273f5562dc12f9559a");
$lifetime = 60 * 60;
// One hour
$f->enableCache("fs", "../resources/cache", $lifetime);
$photos = $f->photos_search(array("tags" => "hongkong, girl", "tag_mode" => "all", "per_page" => "20"));
foreach ($photos['photo'] as $photo) {
    echo "<img src='https://farm" . $photo['farm'] . ".staticflickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . ".jpg'></img>";
    $owner = $f->people_getInfo($photo['owner']);
    echo "<p>" . $owner['username']['_content'] . "</p>";
    /*    $photoInfo = $f->photos_getInfo($photo['id']);
        echo "<p>";
        foreach ($photoInfo['photo']['tags']['tag'] as $tag) {
            echo $tag['_content']." ";
        }
        echo "</p>";*/
    // https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg
    echo "<br><br>";
}
开发者ID:WallaceLau,项目名称:phpFlickrTagger,代码行数:31,代码来源:search.php

示例15: widget

 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     if (empty($title)) {
         $title = false;
     }
     $flickr_api = $instance['flickr_api'];
     $flickr_id = $instance['flickr_id'];
     $number = absint($instance['number']);
     require_once get_template_directory() . "/includes/widgets/phpFlickr/phpFlickr.php";
     $f = new phpFlickr($flickr_api);
     //Insert API key here
     $f->enableCache("fs", get_template_directory() . "/includes/widgets/cache/");
     if (!empty($flickr_id)) {
         echo $before_widget;
         if ($title) {
             echo $before_title;
             echo $title;
             echo $after_title;
         }
         $apikey = $f->people_findByUsername($flickr_api);
         $person = $f->people_findByUsername($flickr_id);
         $photos_url = $f->urls_getUserPhotos($person['id']);
         $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, $number);
         echo "<ul class='flickr_images clearfix'>";
         foreach ((array) $photos['photos']['photo'] as $photo) {
             $photo_url = $f->buildPhotoURL($photo, "Large");
             echo "<li><a class='view flickr-img-link' rel='flickr-gallery' target='_blank' href={$photo_url}>";
             echo "<img class='flickr' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Small") . ">";
             echo "</a></li>";
         }
         echo "</ul>";
         echo $after_widget;
     }
 }
开发者ID:adams0917,项目名称:woocommerce_eht,代码行数:36,代码来源:widget-flickr.php


注:本文中的phpFlickr::enableCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。