Esempio n. 1
0
<?php

/* Last updated with phpFlickr 1.3.2
 *
 * 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.
 *
 */
require_once "phpFlickr.php";
$f = new phpFlickr("bb204b11214e836e196f0481fa7f90b4");
$recent = $f->photos_getRecent(NULL, 1, 1);
foreach ($recent['photo'] as $photo) {
    $owner = $f->people_getInfo($photo['owner']);
    echo "<a href='http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/'>";
    echo $photo['title'];
    echo "</a> Owner: ";
    echo "<a href='http://www.flickr.com/people/" . $photo['owner'] . "/'>";
    echo $owner['username'];
    echo "</a><br>";
}
Esempio n. 2
0
<?php

exit;
/* Last updated with phpFlickr 1.3.2
 *
 * 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("<api key>");
$recent = $f->photos_getRecent();
foreach ($recent['photo'] as $photo) {
    $owner = $f->people_getInfo($photo['owner']);
    echo "<a href='http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/'>";
    echo $photo['title'];
    echo "</a> Owner: ";
    echo "<a href='http://www.flickr.com/people/" . $photo['owner'] . "/'>";
    echo $owner['username'];
    echo "</a><br>";
}
Esempio n. 3
0
<!-- OKTOSHOW --><a href='/classes/viewSource/?path=<?php 
echo $_SERVER['PHP_SELF'];
?>
' target='_blank'>View Source</a><br/><br/><br/>
<?php 
error_reporting(-1);
# Include the PHP Wrapper
require_once "phpFlickr.php";
# Create a new PHP Object
$f = new phpFlickr("48cae78cf83cc1c27f10629e4e451568");
# Fetch all recent photos
$recent = $f->photos_getRecent($jump_to = NULL, $extras = NULL, $per_page = 5, $page = NULL);
foreach ($recent['photos']['photo'] as $thisPhoto) {
    $photoId = $thisPhoto['id'];
    $photoUrl = $f->buildPhotoURL($thisPhoto, $size = "Medium");
    echo "<img src='{$photoUrl}'><br/>";
}
?>



 




Esempio n. 4
0
 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);
 }
Esempio n. 5
0
function getFlickrPhotos($target)
{
    global $blogURL, $pluginURL, $configVal;
    requireModel('reader.common');
    requireComponent('Textcube.Model.Paging');
    requireComponent('Textcube.Function.misc');
    $data = misc::fetchConfigVal($configVal);
    $flickruserid = isset($data['flickruserid']) ? $data['flickruserid'] : "";
    require_once "lib/phpFlickr.php";
    $flickr_api_key = "d1038f051000214af2bf694014ca8f98";
    //It's key for plugin. It does not change.
    $f = new phpFlickr($flickr_api_key);
    $listLength = isset($_GET['length']) ? $_GET['length'] : 16;
    $searchKey = isset($_GET['search']) && !empty($_GET['search']) ? urldecode($_GET['search']) : "";
    $photoSets = isset($_GET['photoSets']) && !empty($_GET['photoSets']) ? $_GET['photoSets'] : "";
    $personMode = isset($_GET['person']) ? $_GET['person'] : "my";
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    $zoomStyle = "flickr";
    ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="<?php 
    echo $pluginURL;
    ?>
/style/default.css" />
	</head>
	<script type="text/javascript">
	//<![CDDA[
		function insertPhoto(_link, _src_m, _src_l, _title, _style){
			var linkTag_A = '', linkTag_B = '', imgTag = '';
			linkTag_A = '<a href="' + _link + '" title="' + _title + '" target="_blank">'; 
			linkTag_B = '</a>';
			imgTag	= '<img src="' + _src_m + '" border="0" />';

			var isWYSIWYG = false;
			try{
				if(parent.editor.editMode == 'WYSIWYG')
					isWYSIWYG = true;
			}
			catch(e){ }
			if(isWYSIWYG) {
				parent.editor.command('Raw', (linkTag_A + imgTag), linkTag_B);
			}else{
				parent.insertTag(parent.editor.textarea, (linkTag_A + imgTag), linkTag_B);
			}
		}
	//]]>
	</script>
	<body style="margin:0;padding:0;border:none;background-color:#ffffff;">
	<div id="photosBody" style="height:200px;width:100%;overflow-x:hidden;overflow-y:auto;background-color:#fff;">
	<?php 
    if ($personMode == "my" && !empty($flickruserid) && empty($searchKey)) {
        if (!empty($photoSets)) {
            $photoset = $f->photosets_getPhotos($photoSets, "owner_name", NULL, $listLength, $page);
            $photos['photos'] = $photoset['photoset'];
        } else {
            $photos = $f->people_getPublicPhotos($flickruserid, NULL, NULL, $listLength, $page);
        }
        foreach ($photos['photos']['photo'] as $photo) {
            $_output = getFlickrPhotosInfo($photo, $zoomStyle, $flickruserid);
            echo $_output;
        }
    } else {
        if (($personMode == "my" || $personMode == "all") && !empty($searchKey)) {
            if ($personMode == "my" && !empty($flickruserid)) {
                $searchArray = array("user_id" => $flickruserid, "text" => $searchKey, "sort" => "date-posted-desc", "per_page" => $listLength, "page" => $page);
            } else {
                $searchArray = array("text" => $searchKey, "sort" => "date-posted-desc", "per_page" => $listLength, "page" => $page);
            }
            $photos['photos'] = $f->photos_search($searchArray);
            if ($photos['photos']['total'] > 0) {
                foreach ($photos['photos']['photo'] as $photo) {
                    $_output = getFlickrPhotosInfo($photo, $zoomStyle);
                    echo $_output;
                }
            } else {
                echo '<p style="margin-top:30px; text-align:center; font-size:9pt;">Flickr did not find any photos. Please input title, description or tags.</p>';
            }
        } else {
            if ($personMode == "all" && empty($searchKey)) {
                $photos['photos'] = $f->photos_getRecent(NULL, $listLength, $page);
                foreach ($photos['photos']['photo'] as $photo) {
                    $_output = getFlickrPhotosInfo($photo, $zoomStyle);
                    echo $_output;
                }
            } else {
                echo '<p style="margin-top:30px; text-align:center; font-size:9pt;">Flickr did not find any photos.', !$nickName ? '(Input title, description or tags.)' : '', '</p>';
            }
        }
    }
    $pageLink = '?person=' . $personMode . '&photoSets=' . $photoSets . '&length=' . $listLength . '&search=' . rawurlencode($searchKey);
    //$photos['total'] = $photos['total'] > 996 ? 996 : $photos['total'];
    $paging = HC_getFetchWithPaging($photos['photos']['total'], $page, $listLength, "{$blogURL}/plugin/flickrPhotos", $pageLink . "&page=");
    $pagingTemplate = '[##_paging_rep_##]';
    $pagingItemTemplate = '<a [##_paging_rep_link_##] class="num">[##_paging_rep_link_num_##]</a>';
    $prev_page = isset($paging['prev']) ? " href=\"{$pageLink}&page={$paging['prev']}\" " : '';
    $next_page = isset($paging['next']) ? " href=\"{$pageLink}&page={$paging['next']}\" " : '';
    $no_more_prev = isset($paging['prev']) ? '' : 'no-more-prev';
    $no_more_next = isset($paging['next']) ? '' : 'no-more-next';
    $target = '<div class="paging-list"><a ' . $prev_page . ' class="prev ' . $no_more_prev . '">prev </a>';
    $target .= '<span class="numbox">' . str_repeat("\t", 12) . Paging::getPagingView($paging, $pagingTemplate, $pagingItemTemplate) . '</span>';
    $target .= '<a ' . $next_page . ' class="next ' . $no_more_next . '"> next</a>';
    $target .= '<div class="totalResults">';
    $target .= 'Total ' . $photos['photos']['total'] . ' photos.';
    $target .= '</div></div>';
    echo $target;
    ?>
	</div>
	</body>
	</html>
	<?php 
}