<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web design London &#124; Joe Smalley &#187; Tutorials</title>
	<atom:link href="http://www.joesmalley.com/blog/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joesmalley.com</link>
	<description></description>
	<lastBuildDate>Fri, 13 May 2011 10:39:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Flickr API website integration</title>
		<link>http://www.joesmalley.com/blog/2009/06/25/flickr-api-website-integration/</link>
		<comments>http://www.joesmalley.com/blog/2009/06/25/flickr-api-website-integration/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 11:45:53 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Website development]]></category>

		<guid isPermaLink="false">http://www.joesmalley.com/blog/?p=15</guid>
		<description><![CDATA[I&#8217;ll be using this blog to give a number of web design and development tutorials and tips. Today i&#8217;m going to explain how to pull your photos from Flickr onto your website, like on my homepage. If you already have a WordPress website you can use the Flickr Widget to do the hard work for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be using this blog to give a number of web design and development tutorials and tips. Today i&#8217;m going to explain how to pull your photos from Flickr onto your website, like on my <a href="http://www.joesmalley.com">homepage</a>. If you already have a WordPress website you can use the <a href="http://wordpress.org/extend/plugins/flickr-widget/">Flickr Widget</a> to do the hard work for you. If you don&#8217;t, or wish to customise how your Flickr photos are displayed, read on&#8230;</p>
<div id="attachment_270" class="wp-caption alignnone" style="width: 296px"><img class="size-full wp-image-270" title="flickr" src="http://www.joesmalley.com/wp-content/uploads/2009/06/flickr.jpg" alt="Flickr API integration on my website" width="286" height="177" /><p class="wp-caption-text">Flickr API integration on my (now old) website</p></div>
<p><span id="more-15"></span><br />
We will be using the <a href="http://phpflickr.com">phpFlickr class</a> which you can download from <a href="http://code.google.com/p/phpflickr/downloads/list">here</a>. Once uploaded to your web server, you will need find three variables:</p>
<ol>
<li>Your Flickr username &#8211; this is usually pretty obvious (mine is &#8220;joesmalley&#8221; &#8211; I know this as the URL to my photos is <a href="http://www.flickr.com/photos/joesmalley/">http://www.flickr.com/photos/joesmalley/</a>).</li>
<li>Your Flickr API key &#8211; you can get yours from <a href="http://www.flickr.com/services/api/key.gne">http://www.flickr.com/services/api/key.gne</a>.</li>
<li>Your Flickr &#8216;secret&#8217; &#8211; you will be given this when you receive your API key.</li>
</ol>
<p>Once you have those three things, you just need some of my PHP wizardry to make it all work:</p>
<pre>&lt;?php

// Settings
$flickrUsername = "";
$flickrApiKey = "";
$flickrSecret = "";
$photosPerRow = 5;
$totalPhotos = 10;

include_once("phpFlickr-2.3.0.1/phpFlickr.php");

if(class_exists('phpFlickr')){

 $f = new phpFlickr($flickrApiKey, $flickrSecret, false );

 if (!empty($f)) {
 $person = $f-&gt;people_findByUsername($flickrUsername);
 $photos_url = $f-&gt;urls_getUserPhotos($person['id']);
 $photos = $f-&gt;people_getPublicPhotos($person['id'], NULL, 1,$totalPhotos);

 // Get the date
 $lastphoto = $f-&gt;photos_getInfo($photos['photos']['photo'][0]['id']);
 echo "&lt;p class=\"flickr-last-updated\"&gt;Last updated: ". date("l M j, Y", $lastphoto['dateuploaded']) ."&lt;/p&gt;
 &lt;ul id='flickr'&gt;";    

 // Get the photos
 $i = 1;
 foreach ($photos['photos']['photo'] as $photo) {

 echo "&lt;li";
 if ($i % $photosPerRow == 0) {
 echo " class=\"last\"";
 }
 echo "&gt;&lt;a href=\"" . $photos_url . $photo['id'] . "\" target=\"_blank\"&gt;";
 echo "&lt;img width=\"50\" height=\"50\" src=\"http://farm".$photo['farm'].".static.flickr.com/".$photo['server']."/".$photo['id']."_".$photo['secret']."_s.jpg\" alt=\"\"/&gt;&lt;/a&gt;&lt;/li&gt;\n";

 $i++;

 }
 }
 echo "&lt;/ul&gt;";

} else {
 echo "Error: phpFlickr has not been imported";
}

?&gt;
<code>
</code></pre>
<p>And some CSS to get it looking nice:</p>
<pre><code>
br.clear {
	clear: both;
	display: block;
	overflow: hidden;
	width: 0;
	height: 0;
}

p.flickr-last-updated{
	color: #999999;
	font-size: 11px;
	margin-bottom: 6px;
}

ul#flickr li{
	display: block;
	float: left;
	margin: 0 4px 4px 0;
	width: 50px;
	height: 50px;
}

ul#flickr li.last{
	margin-right: 0;
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.joesmalley.com/blog/2009/06/25/flickr-api-website-integration/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

