Flickr Photos

I recently signed up to Flickr on a trial and added a few photos to see how it would go. I then enlisted the flickr API to see if I could get the photos on sixfive. It will take me a while to get everything up on flickr, but it shouldnt be too long. There will also be some friends and family only sections for which you will need to sign up to flickr to be able to see.

The best thing about flickr is that it has saved me writing some code to get photos on to the web via a phone camera because you can email phones to your flickr account!

After a quick google search for php flickr, I came out using this nifty script and abstraction for the API specifically for PHP. Now I wrote my own functions to show images in in a couple of functions:

Flickrtags: (This gives you 6 photos with a given tag.)
function flickrtags($tagname){
require_once("phpFlickr/phpFlickr.php");
// Create new phpFlickr object $f = new phpFlickr("41c8bf15de29a34d8e4d3d4e2fbf02f6");

$nsid = $f->people_findByUsername("length");
$photos_red = $f->photos_search(array("user_id"=>$nsid, "tags"=>$tagname, "sort"=>"interestingness-desc", "per_page"=>6));
echo "<div style='text-align:center;'>";
foreach ($photos_red['photo'] as $photo) {
// Build image and link tags for each photo echo "<a xhref=http://www.flickr.com/photos/$photo[owner]/$photo[id]>";
echo "<img border='0' alt='$photo[title]' ".
"src=" . $f->
buildPhotoURL($photo, "Square") . ">";
echo "<br>$photo[title]</a><br><br>";
}
echo "</div>";
}

flickr: (show the last x added photos, if horizontal aligned, then make rows of 6 * x)

function flickr($show,$orientation){
require_once("phpFlickr/phpFlickr.php");
// Create new phpFlickr object $f = new phpFlickr("41c8bf15de29a34d8e4d3d4e2fbf02f6");
if ($orientation != "v"){
$fetch = $show * 8;
}else{
$fetch = $show;
}
$i = 0;
// Find the NSID of the username inputted via the form $nsid = $f->people_findByUsername("length");
// Get the friendly URL of the user's photos $photos_url = $f->urls_getUserPhotos($nsid);
// Get the user's first 36 public photos $photos = $f->people_getPublicPhotos($nsid, NULL, $fetch);
//print_r($photos); echo "<div style='text-align:center;'>";
// Loop through the photos and output the html foreach ($photos['photo'] as $photo) {
echo "<a xhref=$photos_url$photo[id]>";
echo "<img border='0' alt='$photo[title]' ".
"src=" . $f->
buildPhotoURL($photo, "Square") . ">";
echo "</a>";
$i++;
if ($orientation != "v"){
// If it reaches the photo, insert a line break if ($i % 6 == 0) {
echo "<br>\n";
}
}else{
echo "<br>\n";
}
}
echo "</div>";
}

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001.