本文整理汇总了PHP中phpFlickr::photos_getInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP phpFlickr::photos_getInfo方法的具体用法?PHP phpFlickr::photos_getInfo怎么用?PHP phpFlickr::photos_getInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpFlickr
的用法示例。
在下文中一共展示了phpFlickr::photos_getInfo方法的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: 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;
}
示例3: 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 . '">';
}
示例4: phpFlickr
// Insert your Flickr API here:
$f = new phpFlickr("YOUR FLICKR API GOES HERE");
$photos = null;
//Cheap-o caching so it's not fetching a list on every refresh.
$storedCache = unserialize(file_get_contents("./cache/flickrcache"));
if ($storedCache) {
if ($storedCache[0] >= time()) {
echo "<!-- Cached! -->\n\n";
$photos = $storedCache[1];
}
}
if (is_null($photos)) {
echo "<!-- No cache hit -->\n\n";
$tagToSearch = isset($_REQUEST['tag']) ? $_GET['tag'] : "banana";
// Tag is passed in via query string by requesting HTML.
$photos = $f->photos_search(array("tags" => $tagToSearch, "tag_mode" => "all", "per_page" => "500"));
// Stick the results in the cache for five minutes
$storedCache = array(time() + 300, $photos);
file_put_contents("./cache/flickrcache", serialize($storedCache));
}
// Pick a random photo from the array of photo objects returned by phpFlickr
srand((double) microtime() * 1000000);
echo "<!-- Found this many: " . count($photos['photo']) . "-->\n\n";
$randomPhoto = $photos['photo'][rand(0, count($photos['photo']))];
// Construct a link to Flickr's page for the photo.
$imgUrl = "http://static.flickr.com/" . $randomPhoto['server'] . "/" . $randomPhoto['id'] . "_" . $randomPhoto['secret'] . ".jpg";
// Get Flickr's info for this photo for use on the credit line.
$imgInfo = $f->photos_getInfo($randomPhoto['id'], $randomPhoto['secret']);
// Return the display HTML for use by the page (probably in a div).
echo "<img src=" . $imgUrl . "><BR>";
echo "<a href='http://www.flickr.com/photos/" . $randomPhoto['owner'] . "/" . $randomPhoto['id'] . "'>" . $imgInfo['title'] . "</a> by <a href='http://www.flickr.com/people/" . $randomPhoto['owner'] . "/'>" . $imgInfo['owner']['username'] . "</a>";
示例5: count
$secret = "065215435996f0d9";
$page = strip_tags($_GET["p"]);
//$photos = $f->photosets_getPhotos($photoset_id, null, null, 7, $page );
$photos = $f->people_getPublicPhotos('50369640@N04', null, null, 7, $page);
//function people_getPublicPhotos ($user_id, $safe_search = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
echo count($photos);
echo gettype($photos);
echo implode(",", $photos);
echo $photos;
print_r($photos['photos']['photo']);
//exit;
$arr_photos = $photos['photos']['photo'];
foreach ($arr_photos as $photo) {
print_r($photo);
// Build image and link tags for each photo
$photoInfo = $f->photos_getInfo($photo['id']);
print_r($photoInfo);
echo "<li><a href=http://www.flickr.com/photos/" . $photoInfo['photo']['owner']['username'] . "/{$photo['id']}>";
echo "<img border='0' width='768' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Large") . "><div class='metaContainer'><span>" . $photoInfo['photo']['title'] . "</span>";
echo '
</a>
<div class="addthis_toolbox addthis_default_style shareBox">
<a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4cd4693368857545" class="addthis_button_compact">Share</a>
<span class="addthis_separator">|</span>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_bookmark"></a>
<a class="addthis_button_print"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cd4693368857545"></script>
</div>
示例6: execute
//.........这里部分代码省略.........
fclose($r);
chmod($name, 0777);
if ($domain == $wgIFI_AjaxDomain) {
$caption = "{{{$wgIFI_AjaxTemplate}|{$import}}}";
$id = $wgRequest->getVal('id');
if ($domain == "wikimedia.org") {
//maybe we can grab the licnese
$yy = str_replace("http://upload.wikimedia.org/", "", $import);
$parts = split("/", $yy);
$img_title = "";
if (sizeof($parts) == 7) {
$img_title = $parts[5];
} else {
if (sizeof($parts) == 5) {
$img_title = $parts[4];
}
}
if ($img_title != "") {
$url = "http://commons.wikimedia.org/wiki/Image:{$img_title}";
$license = "unknown";
$contents = file_get_contents("http://commons.wikimedia.org/w/index.php?title=Image:{$img_title}&action=raw");
foreach ($wgIFI_ValidLicenses as $lic) {
if (strpos($contents, "{{$lic}") !== false || strpos($contents, "{{self|{$lic}") !== false || strpos($contents, "{{self2|{$lic}") !== false) {
$license = $lic;
break;
}
}
$caption = "{{{$wgIFI_AjaxTemplate}|{$import}|{$url}|{$license}}}";
}
}
} else {
if (!empty($wgIFI_CreditsTemplate)) {
$f = new phpFlickr($wgIFI_FlickrAPIKey);
$info = $f->photos_getInfo($_POST['id']);
$caption = "{{" . $wgIFI_CreditsTemplate . $info['license'] . "|{$_POST['id']}|" . urldecode($_POST['owner']) . "|" . urldecode($_POST['name']) . "}}";
} else {
$caption = wfMsg('importfreeimages_filefromflickr', $_POST['t'], "http://www.flickr.com/people/" . urlencode($_POST['owner']) . " " . $_POST['name']) . " <nowiki>{$import}</nowiki>. {{CC by 2.0}} ";
}
}
$caption = trim($caption);
$t = $_POST['ititle'];
// handle duplicate filenames
$i = strrpos($import, "/");
if ($i !== false) {
$import = substr($import, $i + 1);
}
// pretty dumb way to make sure we're not overwriting previously uploaded images
$c = 0;
$nt =& Title::makeTitle(NS_IMAGE, $import);
$fname = $import;
while ($nt->getArticleID() && $c < 20) {
$fname = $c . "_" . $import;
$nt =& Title::makeTitle(NS_IMAGE, $fname);
$c++;
}
$import = $fname;
/*
$arr = array ( "size" => $size, "tempname" => $name,
"caption" => $caption,
"url" => $import, "title" => $_POST['t'] );
*/
$filename = trim(urldecode($wgRequest->getVal('ititle', null)));
if ($filename == "undefined") {
$filename = wfTimestampNow();
}
$filename .= "_";
示例7: elseif
</td>
<?php
if (!(($key + 1) % 3)) {
echo "</tr>\n<tr>";
}
}
echo "</tr></table>";
} else {
echo "No matching pictures were found.<!-- refresh me -->";
}
}
} elseif ($this->attributes['details']['show'] == "advanced") {
if (isset($this->attributes['details']['photos']) && count($this->attributes['details']['photos']) > 0) {
echo "<table cellpadding='3' style='border: none; width: 100%'>\n<tr>";
foreach (split(",", $this->attributes['details']['photos']) as $key => $photoID) {
$photo = $f->photos_getInfo($photoID);
$isError = $f->getErrorMsg();
if (!$isError) {
if (!isset($photo['urls']['url']) || count($photo['urls']['url']) < 1) {
//$photopage = "http://www.flickr.com/photos/" . $photo['owner']['nsid'] . "/" . $photo['id'] . "/";
$photopage = "http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'];
} else {
foreach ($photo['urls']['url'] as $photopage) {
if ($photopage['type'] == "photopage") {
$photopage = $photopage['_value'];
}
}
}
?>
<td style="vertical-align: top; text-align: center; width: 33%">
<a href="<?php
示例8: uploadImage
/**
* Accept a request to upload an image either via POST data (user upload)
* or via flickr or google / wikimedia.org search.
*
* @param $src string with value 'upload', 'flickr' or 'wiki'
* @return html outputs image details page
*/
private function uploadImage($src, $fromIIA = false)
{
global $wgRequest, $wgUser, $IP, $wgOut;
$error = '';
$debugInfo = array();
if ($src == 'upload') {
$tempname = TempLocalFile::createTempFilename();
$file = new TempLocalFile(Title::newFromText($tempname, NS_IMAGE), RepoGroup::singleton()->getLocalRepo());
$name = $wgRequest->getFileName('wpUploadFile');
$file->upload($wgRequest->getFileTempName('wpUploadFile'), '', '');
$comment = '';
$filesize = $file->getSize();
if (!$filesize) {
$error = wfMsg('eiu-upload-error');
}
} elseif ($fromIIA || $src == 'flickr' || $src == 'wiki') {
$sourceName = $fromIIA || $src == 'flickr' ? 'Flickr' : 'Mediawiki Commons';
$tempname = TempLocalFile::createTempFilename();
$file = new TempLocalFile(Title::newFromText($tempname, NS_IMAGE), RepoGroup::singleton()->getLocalRepo());
$details = (array) json_decode($wgRequest->getVal('img-details'));
$name = $details['name'];
// scrape the file using curl
$filename = '/tmp/tmp-curl-' . mt_rand(0, 100000000) . '.jpg';
$remoteFile = strlen($details['url_l']) ? $details['url_l'] : $details['url'];
$ch = curl_init($remoteFile);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$fp = fopen($filename, 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
$ret = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
fclose($fp);
if ($err) {
$debugInfo['curl'] = $err;
}
$filesize = @filesize($filename);
if ($filesize) {
if ($fromIIA || $src == 'flickr' || preg_match('@^http://[^/]*flickr@', $details['url'])) {
require_once $IP . '/extensions/3rdparty/phpFlickr-2.3.1/phpFlickr.php';
$flickr = new phpFlickr(WH_FLICKR_API_KEY);
$photo = $flickr->photos_getInfo($details['photoid']);
$err = $flickr->getErrorMsg();
if ($err) {
$debugInfo['flickrAPI'] = $err;
}
$license = $photo['license'];
$username = $photo['owner']['username'];
$comment = '{{flickr' . intval($license) . '|' . wfEscapeWikiText($details['photoid']) . '|' . wfEscapeWikiText($details['ownerid']) . '|' . wfEscapeWikiText($username) . '}}';
} else {
$comment = self::getWPLicenseTag($details['url']);
}
// finish initializing the $file obj
$status = $file->upload($filename, '', '');
if (!$status->ok) {
$error = wfMsg('eiu-upload-error');
}
} else {
$error = wfMsg('eiu-download-error', $sourceName);
}
}
if ($error) {
$html = EasyTemplate::html('eiu_file_error.tmpl.php', array('error' => $error));
$wgOut->addHTML($html);
error_log("file from {$src} error msgs: " . print_r($debugInfo, true));
} else {
$mwname = $tempname;
if (!$fromIIA) {
$props = array('src' => $src, 'name' => $name, 'mwname' => $mwname, 'is_image' => $file->media_type == 'BITMAP' || $file->media_type == 'DRAWING', 'width' => $file->width, 'height' => $file->height, 'upload_file' => $file, 'image_comment' => $comment, 'license' => $wgUser->getOption('image_license'));
$html = EasyTemplate::html('eiu_image_details.tmpl.php', $props);
$wgOut->addHTML($html);
} else {
$this->insertImage('', $name, $mwname, true, $comment);
}
}
}
示例9: substr
$defwords = substr($defwords, 0, strLen($defwords) - 4);
//this will eat the last OR
//echo $defwords;
unset($argst);
$argst = array("text" => "" . $defwords . "", "min_taken_date" => "" . $fsdate . "", "max_taken_date" => "" . $fedate . "", "per_page" => "20", "sort" => "relevance", "page" => "1");
//print_r($argst);
$triathlondaily = $f->photos_search($argst);
//print_r($triathlondaily);
for ($x = 0; $x <= 15; $x++) {
$photosre = '';
$photosre = $triathlondaily[photo][$x];
$photo_id = '';
$photo_id = $triathlondaily[photo][$x][id];
//echo $photo_id;
// need to find photo username to get data to allow form piciture flickr url
$photoid = $f->photos_getInfo($photo_id, $secret);
//print_r($photoid);
//echo $photoid[urls][url][$x][_content];
$image = $f->buildPhotoURL($photosre, $size = "Thumbnail");
$imgtoday[$x][url] = $photoid[urls][url][0][_content];
$imgtoday[$x][title] = $photoid[title];
$imgtoday[$x][image] = $image;
//print_r($imgtoday);
}
//closes forloop
/*<div class="rphoto"><a href="<?php echo $photoid[urls][url][0][_content]?>" title="<?php echo $photoid[title]?>"><img src="<?php echo $image ?>" border ="1" /></a></div>
*/
if ($imgtoday) {
$db->query = "INSERT INTO " . RSSDATA . ".imagesource (idstart, orderid, imgurl, title, sourceurl, enddate) VALUES ";
foreach ($imgtoday as $key => $meimg) {
$smeurl = mysql_real_escape_string($meimg[url]);
示例10: phpFlickr
<?php
require_once 'phpFlickr.php';
$flickrObject = new phpFlickr("46dea5f6abb12aed7a823adb7ecf5816");
$pics_file = fopen("pics_file_temp.txt", "w") or die("Unable to open file!");
$photos = $flickrObject->photos_search(array("tags" => "trip,travel,vacation,objects,color,- people,- person,- bikini,- human", "tag_mode" => "any", "per_page" => "50", "sort" => "interestingness-desc", "content_type" => "1", "safe_search" => "1", "license" => "9"));
//Initializing variables
$imageCounter = 0;
$idArrayImages = array();
//For each Picture
foreach ($photos['photo'] as $photo) {
//Console Log image message counter
echo "Image: " . $imageCounter++ . " / ";
//We get the Information of each photo giving the Photo_ID
$photo_info = $flickrObject->photos_getInfo($photo['id']);
echo $photo["id"] . ' - ';
if (in_array($photo['id'], $idArrayImages)) {
echo "Hay una imagen repetida";
}
$idArrayImages[] = $photo['id'];
//Uncomment this line to see the PUBLIC URL of the photo
//echo $photo_info['photo']['urls']['url'][0]['_content']."\n";
//We stract the TAGS array for each photo
$array_tags = $photo_info['photo']['tags']['tag'];
//Get the different sizes of the image
$photo_sizes = $flickrObject->photos_getSizes($photo['id']);
//We look the optimal size
foreach ($photo_sizes as $size) {
//Only get Medium Images for file sizes proposes
if ($size['label'] == 'Medium 640') {
$url = $size['source'];
示例11: explode
}
?>
<div class="flickr">
<?php
$url_elements = parse_url($node->field_flickr[0]['embed']);
$flickr_path = explode('/', $url_elements['path']);
if (module_exists('keys')) {
$flickr_api_key = keys_get_key('flickr_theme_helper');
}
$f = new phpFlickr($flickr_api_key, NULL, FALSE);
if (module_exists('fenchurch')) {
$f->enableCache('db', fenchurch_flickr_cache_db_url(), variable_get('fenchurch_flickr_cache_lifetime', 64000));
}
$flickr_photo_info = $f->photos_getInfo($flickr_path[3]);
?>
<?php
print $node->field_flickr[0]['view'];
?>
<?php
if ($node->location) {
$photo_latitude = $node->location['latitude'];
$photo_longitude = $node->location['longitude'];
if (function_exists('theme_gmap') && $page) {
$photo_markers = array('id' => 'photo_markers', 'zoom' => 11, 'width' => '500px', 'height' => '200px', 'type' => 'Map', 'text' => $node->title, 'latitude' => $photo_latitude, 'longitude' => $photo_longitude, 'markers' => array(array('markername' => '', 'latitude' => $photo_latitude, 'longitude' => $photo_longitude)));
print theme('gmap', array('#settings' => $photo_markers));
}
// function_exists('theme_gmap')
示例12:
}
/* ------------------------------------
:: GRID ONLY
------------------------------------ */
if ($NV_show_slider == 'gridgallery') {
$output .= '<div class="nv-sortable row">';
}
/* ------------------------------------
:: GRID ONLY *END*
------------------------------------ */
foreach ($photos['photoset']['photo'] as $photo) {
$photodata = $f->photos_getInfo($photo['id']);
if ('video' == $photodata['photo']['media']) {
$sizes = $f->photos_getSizes($photo['id']);
$NV_movieurl = $sizes[6]["source"];
// Movie File URL
$NV_videotype = 'swf';
$NV_previewimgurl = '';
} else {
$NV_previewimgurl = $f->buildPhotoURL($photo, $img_size);
// Preview Image URL
}
$NV_posttitle = $photo['title'];
$NV_description = $photo['description'];
$NV_disablegallink = '';
$NV_galexturl = 'http://www.flickr.com/photos/' . $user;
$NV_disablereadmore = 'yes';
示例13: elseif
echo '<img src="' . $f->buildPhotoURL($photo, $viewsize) . '" title="' . $photo['title'] . '" />';
echo '</a>';
echo '</td>';
$row = 6;
if ($viewsize == "square" || $viewsize == "thumbnail") {
$row = 6;
} elseif ($viewsize == "small") {
$row = 3;
} else {
$row = 1;
}
if ($count % $row == 0) {
echo '</tr><tr>';
}
}
echo '</tr>';
echo '</table>';
/************************************************************************************************/
/**
* Show page with photos
*/
} elseif ($todo == "getphoto") {
$photo_id = $_REQUEST['photo_id'];
$insertsize = $_REQUEST['insertsize'] == "" ? "small" : $_REQUEST['insertsize'];
$linksize = $_REQUEST['linksize'] == "" ? "medium" : $_REQUEST['linksize'];
require_once "phpFlickr.php";
$f = new phpFlickr($api_key);
$photo = $f->photos_getInfo($photo_id);
echo '<a href="' . $f->buildPhotoURL($photo, $linksize) . '" title="' . $photo['title'] . '"><img src="' . $f->buildPhotoURL($photo, $insertsize) . '" alt="' . $photo['title'] . '" title="' . $photo['title'] . '" /></a>';
/************************************************************************************************/
}
示例14: explode
// if it's not a dead link, then we can make API calls!
$url_elements = parse_url(check_url($node->field_url['0']['display_url']));
if (strstr($url_elements['host'], 'flickr.com') && !strstr($url_elements['path'], "tags")) {
$flickr_path = explode('/', $url_elements['path']);
if (!class_exists('phpFlickr')) {
require_once fenchurch_flickr_library_path() . '/phpFlickr.php';
}
if (module_exists('keys')) {
$flickr_api_key = keys_get_key('flickr_theme_helper');
}
$f = new phpFlickr($flickr_api_key, NULL, FALSE);
if (module_exists('fenchurch')) {
$f->enableCache('db', fenchurch_flickr_cache_db_url(), variable_get('fenchurch_flickr_cache_lifetime', 64000));
}
if ($flickr_path[1] == 'photos' && is_numeric($flickr_path[3])) {
$flickr_photo_info = $f->photos_getInfo($flickr_path[3]);
$thumbnail_url = 'http://farm' . $flickr_photo_info['farm'] . '.static.flickr.com/' . $flickr_photo_info['server'] . '/' . $flickr_photo_info['id'] . '_' . $flickr_photo_info['secret'] . '_s.jpg';
} else {
if ($flickr_path[1] == 'photos' && $flickr_path[3] == 'sets') {
$flickr_photo_set_info = $f->photosets_getInfo($flickr_path[4]);
$flickr_photo_info = $f->photos_getInfo($flickr_photo_set_info['primary']);
$thumbnail_url = 'http://farm' . $flickr_photo_info['farm'] . '.static.flickr.com/' . $flickr_photo_info['server'] . '/' . $flickr_photo_info['id'] . '_' . $flickr_photo_info['secret'] . '_s.jpg';
}
}
}
if ($thumbnail_url) {
print '<div class="website-thumbnail">';
$thumbnail = theme('image', $thumbnail_url, $title, '', NULL, FALSE);
$link_attributes = array();
$link_attributes['rel'] = $dead_link ? 'nofollow' : NULL;
$link_attributes['html'] = TRUE;
示例15: 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);
}