本文整理汇总了PHP中phpFlickr类的典型用法代码示例。如果您正苦于以下问题:PHP phpFlickr类的具体用法?PHP phpFlickr怎么用?PHP phpFlickr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了phpFlickr类的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']);
}
示例2: nextend_api_auth_flow
function nextend_api_auth_flow()
{
$api_key = NextendRequest::getVar('api_key');
$api_secret = NextendRequest::getVar('api_secret');
if (session_id() == "") {
@session_start();
}
if (!$api_key || !$api_secret) {
$api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
$api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
} else {
$_SESSION['api_key'] = $api_key;
$_SESSION['api_secret'] = $api_secret;
}
if ($api_key && $api_secret) {
require_once dirname(__FILE__) . "/api/phpFlickr.php";
$f = new phpFlickr($api_key, $api_secret);
if (empty($_GET['frob'])) {
$f->auth('read', false);
} else {
$result = $f->auth_getToken($_GET['frob']);
unset($_SESSION['api_key']);
unset($_SESSION['api_secret']);
unset($_SESSION['phpFlickr_auth_token']);
echo '<script type="text/javascript">';
echo 'window.opener.setToken("' . $result['token'] . '");';
echo '</script>';
}
}
}
示例3: getValidation
function getValidation($username, $apiKey, $secretKey)
{
$this->loadPhpFlickrClasses();
$service = new phpFlickr($apiKey, $secretKey);
$nsid = $service->people_findByUsername($username);
return $nsid;
}
示例4: searchFlickrPhotoDetail
function searchFlickrPhotoDetail($id, $type)
{
$retval = array();
$data = array();
$f = new phpFlickr('5bc169cff7b9121c0c93f9b8804b1116');
$photo = $f->photos_getInfo($id);
$tags = '';
foreach ($photo['tags']['tag'] as $tag) {
$tags .= $tag['raw'] . ',';
//$tag['raw']
}
$notes = array();
foreach ($photo['notes']['note'] as $note) {
$notes[] = $note['_content'];
}
$urls = array();
foreach ($photo['urls']['url'] as $url) {
$urls = $url['_content'];
}
$data = array('title' => $photo['title'], 'description' => $photo['description'], 'image' => $f->buildPhotoURL($photo), 'date' => $photo['dates']['taken'], 'author' => $photo['owner']['username'], 'authorUrl' => 'http://flickr.com/photos/' . $photo['owner']['nsid'], 'tags' => $tags, 'note' => $notes, 'url' => $urls);
$retval['status'] = 'OK';
$retval['statusmsg'] = 'OK';
$retval['data'] = $data;
return $retval;
}
示例5: getFotos
public function getFotos()
{
$f = new phpFlickr("f8dfa483443f9424a79d73c50344b90c");
//Clase de Api, conseguir en: http://www.flickr.com/services/api/keys/
$nsid = "139950084@N02";
//NSID Usuario, conseguir en: http://idgettr.com/
//Incluir tag, ordenamieno, privacidad, y numero de imagenes a mostrar
$tagsList = $f->tags_getListUser($nsid);
$j = 0;
foreach ($tagsList as $tagl) {
$photos = $f->photos_search(array("tags" => $tagl['_content'], "user_id" => $nsid, "sort" => "date-posted-desc", "privacy_filter" => "1"));
//$photoList[$tagl['_content']] = $photos['photo'];
$i = 0;
$photoList[$j]['tag'] = $tagl['_content'];
foreach ($photos['photo'] as $photo) {
$photoList[$j]['photos'][$i]['id'] = $photo['id'];
$photoList[$j]['photos'][$i]['url'] = $f->buildPhotoURL($photo, "Medium 640");
$i++;
}
$j++;
/* if (is_array($photos['photo'])){
$i = 0;
foreach ($photos['photo'] as $photo){
$photoList[$tagl['_content']][$i] = $f->buildPhotoURL($photo, "Medium 640");
}
}*/
}
return $photoList;
}
示例6: onNextendFlickr
function onNextendFlickr(&$flickr)
{
$config = new NextendData();
$config->loadJson(NextendSmartSliderStorage::get(self::$_group));
require_once dirname(__FILE__) . "/api/phpFlickr.php";
$flickr = new phpFlickr($config->get('apikey', ''), $config->get('apisecret', ''));
$flickr->setToken($config->get('token', ''));
}
示例7: 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;
}
示例8: flickr_show_set
function flickr_show_set($set_id, $size = 's', $start = 0, $limit = 0, $bigsize = '')
{
global $FLICKR_API_KEY;
$f = new phpFlickr($FLICKR_API_KEY);
$set = $f->photosets_getPhotos($set_id);
$start = $start;
$limit = $limit > 0 ? $limit : count($set['photo']);
flickr_output_from_set($set, $size, $start, $limit, $bigsize);
}
示例9: uploadPhoto
function uploadPhoto($path, $title)
{
$apiKey = "3b7d4ab3e54988c4e6fd59d9e40ca28c";
$apiSecret = "84d2e480c8e3c926";
$permissions = "write";
$token = "72157626228984291-4635fa88a6fed8f5";
$f = new phpFlickr($apiKey, $apiSecret, true);
$f->setToken($token);
return $f->async_upload($path, $title);
}
示例10: upload_photo
function upload_photo($path, $title)
{
$apiKey = "your-flickr-key";
$apiSecret = "your-flickr-secret";
$token = "flickr-token";
$permissions = "write";
$f = new phpFlickr($apiKey, $apiSecret, true);
$f->setToken($token);
$f->async_upload($path, $title);
@unlink("temp.jpg");
}
示例11: total_photo
function total_photo($tags)
{
$o = new phpFlickr('6791ccf468e1c2276c1ba1e0c41683a4');
$d = $o->photos_search(array('tags' => $tags, 'content_type' => 1, 'sort' => 'date-posted-asc', 'extras' => 'url_o,url_l', 'page' => 1, 'per_page' => 500));
print_r("total page :" . $d['pages']);
$total_page = $d['pages'];
print_r("total photo :" . $d['total']);
$total_photo = $d['total'];
$dir = str_replace(" ", "_", $tags);
system(" mkdir {$dir}");
photo_list($tags, 1, 500);
}
示例12: 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;
}
示例13: uploadPhoto
function uploadPhoto($path, $title)
{
$apiKey = "e0fb27a9db978169247afe3169afba43";
$apiSecret = "d9a3f7d933ae7ccf";
$permissions = "write";
$token = "72157662014557483-df831fa3afbc5468";
$f = new phpFlickr($apiKey, $apiSecret, true);
$f->setToken($token);
$result = $f->sync_upload($path, $title);
$photo = $f->photos_getInfo($result);
print_r($photo);
$src = 'http://farm' . $photo['photo']['farm'] . '.staticflickr.com/' . $photo['photo']['server'] . '/' . $photo['photo']['id'] . '_' . $photo['photo']['secret'] . '.' . $photo['photo']['originalformat'];
$src = 'https://c1.staticflickr.com/' . $photo['photo']['farm'] . '/' . $photo['photo']['server'] . '/' . $photo['photo']['id'] . '_' . $photo['photo']['secret'] . '_n.jpg';
echo '<br><img src="' . $src . '">';
}
示例14: jeg_get_flickr_photo
function jeg_get_flickr_photo($flickrapi, $flickrid, $totalimage)
{
require_once JEG_PLUGIN_DIR . "util/phpFlickr/phpFlickr.php";
$f = new phpFlickr($flickrapi);
$result = $f->people_getPublicPhotos($flickrid, null, null, $totalimage, null);
$photos = array();
if (empty($result)) {
echo $f->getErrorMsg();
} else {
$photosUrl = $f->urls_getUserPhotos($flickrid);
foreach ($result['photos']['photo'] as $photo) {
$photos[] = array('s' => $f->buildPhotoURL($photo, 'square'), 'url' => $photosUrl . $photo['id'], 'title' => $photo['title']);
}
}
return $photos;
}
示例15: 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());
}