PHP 照片库通过flickr API

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 照片库通过flickr API相关的知识,希望对你有一定的参考价值。

require_once("phpFlickr/phpFlickr.php");

$username = "";
$apiKey = "";
$apiSecret ="";

	// Create new phpFlickr object
	
	$f = new phpFlickr($apiKey, $apiSecret);
	
	$f->enableCache("db","mysql://<dbname>:<dbpass>@mysql.localhost/<dbname>");
	//$flickr->enableCache("fs", "/var/www/phpFlickrCache");

	// Find the NSID of the username inputted via the form
        $nsid = $f->people_findByUsername($username);
   
	function returnPhotosDetailView($f,$setid) {
		
		$photosSetInfo = $f->photosets_getInfo($setid);
		$heading = "Photos: ".$photosSetInfo['title'];
		$photos = $f->photosets_getPhotos($setid, NULL, NULL);						
                $i=0;
		$html .= "<ul id='photos-list' class='clearfix'>\n";	
		
		
		foreach ($photos['photo'] as $photo) {        
		    $i++; 
		    if ($i % 6 == 0) {
         	   $html .="<li class='right'>\n";
        	} else {
        	   $html .="<li>\n";
        	}
        	
        	
        	$html .=  "<a href='".$f->buildPhotoURL($photo, "medium")."' rel='lightbox' class='vtip round shadow' title='© All rights reserved'>";
        	
        	$html .= "<img alt='$photo[title]' ".
            "src='".$f->buildPhotoURL($photo, "square")."' id='photo_".$photo['id']."' width='75' height='75' /></a>\n";
            $html .="</li>\n";
                   	
    	}	
    	    	
    	$html .="</ul>";
    	 
    	return $html;
    	
    	echo $html;		
	
}
	
$action = "detailview";
$setid  = "";
$pid    =  rawurlencode($_GET['pid']);	

$img_out = returnPhotosDetailView($f,$setid);
$smarty->assign("img_out",$img_out);

以上是关于PHP 照片库通过flickr API的主要内容,如果未能解决你的问题,请参考以下文章

PHP Flickr照片引入PHP JSON

PHP 使用PHP Flickr最近的照片到HTML

PHP 根据主题获取大型flickr照片

备份flickr照片集

我在用这个 flickr api 查询做啥?

PHP PHP Media API类(YouTube,Flickr,Vimeo,Bitly)