<?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>Nakunakifi &#187; Google</title>
	<atom:link href="http://www.nakunakifi.com/category/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nakunakifi.com</link>
	<description>More inane ramblings (as if there wasn't enough on the interweb thingy already)</description>
	<lastBuildDate>Sun, 28 Jun 2009 17:42:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Integrate Google Picasa into your website with PHP Part2</title>
		<link>http://www.nakunakifi.com/2008/10/how-to-integrate-google-picasa-into-your-website-with-php-part2/</link>
		<comments>http://www.nakunakifi.com/2008/10/how-to-integrate-google-picasa-into-your-website-with-php-part2/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 12:28:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://www.nakunakifi.com/?p=188</guid>
		<description><![CDATA[
In this follow on article to &#8216;How to Integrate Google Picasa into your website with PHP&#8216; I will explain how to display thumbnails of the photos contained in your Google Picasa albums.
Step by Step
Step 1
Firstly, make sure you have familairised yourself with Part 1 of this series
Step 2
Set up the variables to grab the photo [...]]]></description>
			<content:encoded><![CDATA[<p><img class="imgborder" src="http://www.nakunakifi.com/wp-content/uploads/2008/10/picasa2.jpg" alt="" title="picasa2" width="500" height="174" class="alignnone size-full wp-image-190" /></p>
<p>In this follow on article to &#8216;<a href="http://www.nakunakifi.com/how-to-integrate-google-picasa-into-your-website">How to Integrate Google Picasa into your website with PHP</a>&#8216; I will explain how to display thumbnails of the photos contained in your Google Picasa albums.</p>
<h2>Step by Step</h2>
<h2>Step 1</h2>
<p>Firstly, make sure you have familairised yourself with <a href="http://www.nakunakifi.com/how-to-integrate-google-picasa-into-your-website">Part 1</a> of this series</p>
<h2>Step 2</h2>
<p>Set up the variables to grab the photo album id, the photo id and the page number . A little explanation, $albumId grabs the album id from the album thumbnail you clicked.  $page is the page number being displayed. $maxResults is the number of photos to display on a page.</p>
<pre>
&nbsp;&nbsp;&nbsp;&nbsp;$albumId = $_GET[&#039;albumId&#039;] ;
&nbsp;&nbsp;&nbsp;&nbsp;$page = $_GET[&#039;page&#039;];
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// the size of the photo to embed 
&nbsp;&nbsp;&nbsp;&nbsp;// 800 is the max size google allow you to embed
&nbsp;&nbsp;&nbsp;&nbsp;// The acceptable values are 144, 288, 400, 640,s720 and 800
&nbsp;&nbsp;&nbsp;&nbsp;$maxImageSize = 800;&nbsp;&nbsp;
</pre>
<h2>Step 3</h2>
<p>Load the required Zend classes and authenticate </p>
<pre>
&nbsp;&nbsp;&nbsp;&nbsp;require_once &#039;Zend/Loader.php&#039;;
&nbsp;&nbsp;&nbsp;&nbsp;Zend_Loader::loadClass(&#039;Zend_Gdata_Photos&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;Zend_Loader::loadClass(&#039;Zend_Gdata_ClientLogin&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;Zend_Loader::loadClass(&#039;Zend_Gdata_AuthSub&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;Zend_Loader::loadClass(&#039;Zend_Gdata_Photos_PhotoQuery&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;Zend_Loader::loadClass(&#039;Zend_Gdata_Photos_AlbumQuery&#039;);
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// Authenticate
&nbsp;&nbsp;&nbsp;&nbsp;// Parameters for ClientAuth authentication
&nbsp;&nbsp;&nbsp;&nbsp;$serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
&nbsp;&nbsp;&nbsp;&nbsp;$user = &quot;username&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;$pass = &quot;password&quot;;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// Create an authenticated HTTP client
&nbsp;&nbsp;&nbsp;&nbsp;$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $serviceName);
&nbsp;&nbsp;&nbsp;&nbsp;$photos = new Zend_Gdata_Photos($client);&nbsp;&nbsp;
&nbsp;
</pre>
<h2>Step 4</h2>
<p>The meat and veg&#8230;</p>
<pre>
function outputPhotoFeed($client, $user, $albumId, $photoId, $numResults, $maxResults, $page)
{
&nbsp;&nbsp;global $maxImageSize ;
&nbsp;&nbsp;&nbsp;&nbsp;$photos = new Zend_Gdata_Photos($client); 
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// List photos from album
&nbsp;&nbsp;&nbsp;&nbsp;if( !isset($albumId)) 
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;grid&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;Choose a photo album to view.&lt;/p&gt;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;} 
&nbsp;&nbsp;&nbsp;&nbsp;else 
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;$query = $photos-&gt;newAlbumQuery();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setUser(&quot;default&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setAlbumId($albumId);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setImgMax($maxImageSize); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setMaxResults($maxResults);
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(isset($page)) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setStartIndex((($page-1) * $maxResults)+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;grid&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$albumFeed = $photos-&gt;getAlbumFeed($query);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Number of results
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$numResults = $albumFeed-&gt;gphotoNumPhotos-&gt;text;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $albumName = $albumFeed-&gt;getTitle();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?&gt; &lt;h3&gt;Photos from &lt;?php echo $albumName ?&gt;&lt;/h3&gt;
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp; &lt;?php
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// You should probably check if $numResults is a number&#46;..
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// If there are more than $maxResults, we need to paginate this&#46;..
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$numPages = ceil($numResults / $maxResults);
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if($numPages &gt; 1) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo Paginate( $numPages, $page, $albumName, $albumId);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach ( $albumFeed as $photoEntry) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// get image title
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// $title = $photoEntry-&gt;getTitle();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// echo &quot;title = $title&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$contentUrl = &quot;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$thumbnailUrl = &quot;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title = $photoEntry-&gt;getSummary();
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( $photoEntry-&gt;getMediaGroup()-&gt;getContent() != null) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mediaContentArray = $photoEntry-&gt;getMediaGroup()-&gt;getContent();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$contentUrl = $mediaContentArray[0]-&gt;getUrl();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( $photoEntry-&gt;getMediaGroup()-&gt;getThumbnail() != null) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mediaThumbnailArray = $photoEntry-&gt;getMediaGroup()-&gt;getThumbnail();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$thumbnailUrl = $mediaThumbnailArray[1]-&gt;getUrl();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;div class=&#039;photo&#039;&gt;&lt;a title=&#039;&quot; . $title .&quot;&#039; rel=&#039;lightbox[$albumId]&#039; href=&#039;&quot;.$contentUrl.&quot;&#039;&gt;&lt;img src=&#039;&quot; . $thumbnailUrl . &quot;&#039; alt=&#039;&quot; . $photoEntry-&gt;title-&gt;text .&quot;&#039; title=&#039;&quot; . $title .&quot;&#039; /&gt;&lt;/a&gt;&lt;/div&gt;\n&quot;; 
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;div style=&#039;clear:both;margin-bottom:6px;&#039;&gt;&amp;nbsp;&lt;/div&gt;&quot;;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( $numPages &gt; 1) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo Paginate( $numPages, $page, $albumName, $albumId);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} 
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Zend_Gdata_App_HttpException $e) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Error: &quot; . $e-&gt;getMessage() . &quot;&lt;br /&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($e-&gt;getResponse() != null) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Body: &lt;br /&gt;\n&quot; . $e-&gt;getResponse()-&gt;getBody() . 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&lt;br /&gt;\n&quot;; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} 
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Zend_Gdata_App_Exception $e) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Error: &quot; . $e-&gt;getMessage() . &quot;&lt;br /&gt;\n&quot;; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</pre>
<h2>Step 5</h2>
<p>Call the main function</p>
<pre>
outputPhotoFeed($client, $user, $albumId, $photoId, $numResults, $maxResults, $page) ;
&nbsp;
</pre>
<h2>Step 6</h2>
<p><img class='imgborder' src="http://www.nakunakifi.com/wp-content/uploads/2008/10/pagination.jpg" alt="" title="pagination" width="500" height="174" class="alignnone size-full wp-image-208" /></p>
<p>Paging through the result set is managed with the function &#8216;Pages()&#8217; </p>
<pre>
function Pages( $numPages, $currentPage, $albumName, $albumId) 
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Create page links
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$pagination = &quot;&lt;ul class=&#039;page-nav&#039;&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for( $i=1 ; $i &lt;= $numPages ; $i++ ) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$class = &quot;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Is this the current page current page?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// add class
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( $i == $currentPage) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$class = &quot; class=&#039;selected&#039;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$pagination .= &quot;&lt;li&quot;.$class.&quot;&gt;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$pagination .= &quot;&lt;a href=&#039;?albumId=&quot;.$albumId.&quot;&amp;amp;albumName=&quot;.$albumName.&quot;&amp;amp;page=&quot;.$i.&quot;&#039;&gt;&quot;.$i.&quot;&lt;/a&gt;&lt;/li&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$pagination .= &quot;&lt;/ul&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $pagination;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
</pre>
<h2>Conclusion</h2>
<p>So now we know how to display thumbnails of your Picasa Web albums into your website aswell as showing the photos in the albums. Next time I will show you how to sex it with the fabulous <a href="http://www.huddletogether.com/projects/lightbox2/" target='_blank'>LightBox2</a> </p>
<p><a href='http://www.nakunakifi.com/wp-content/uploads/2008/10/integrate-picasa-with-php.zip'>Download source code (.zip)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nakunakifi.com/2008/10/how-to-integrate-google-picasa-into-your-website-with-php-part2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Integrate Google Picasa into your website with PHP</title>
		<link>http://www.nakunakifi.com/2008/10/how-to-integrate-google-picasa-into-your-website/</link>
		<comments>http://www.nakunakifi.com/2008/10/how-to-integrate-google-picasa-into-your-website/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 10:28:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://192.168.1.5/~ik/nakunakifi/?p=45</guid>
		<description><![CDATA[
In a recent project I needed to have a simple way for the client to be able to display their snapshots on their website. I thought Google Picasa Web Albums would be ideal for this and began to put the wheels in motion. The end results can be seen in action here. Today I thought [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.nakunakifi.com/wp-content/uploads/2008/10/picasa1.png" alt="" title="picasa1" width="500" height="174" class="imgborder" /></p>
<p>In a recent project I needed to have a simple way for the client to be able to display their snapshots on their website. I thought Google <a href="http://code.google.com/apis/picasaweb/overview.html" target="_blank">Picasa Web Albums</a> would be ideal for this and began to put the wheels in motion. The end results can be seen in action <a href="http://www.mkennerleyandson.co.uk" target="_blank">here</a>. Today I thought I would share with you how I went about this.</p>
<p>OK grab yourself some strong coffee or a bevarage of your own choice and lets get started. </p>
<p>This &#8216;how to&#8217; assumes you have a fairly decent knowledge of PHP and that you already have installed the Google Data PHP Client Library, this is part of the <a href="http://framework.zend.com/download/overview" target="_blank">Zend Framework</a>. If not get this done at head right back here.</p>
<h2>Step by Step</h2>
<h3>Step 1</h3>
<p>First of all you require a <a href="http://picasaweb.google.com/" target="_blank">Google account</a>, if you don&#8217;t have one grab one of those (they are free) and head right back here.</p>
<h3>Step 2</h3>
<p>If you haven&#8217;t done so already, upload some albums. You can do this either through iPhoto using <a href="http://picasa.google.com/mac_tools.html" target="_blank">Picasa Web Albums Uploader</a> utility on a Mac or <a href="http://picasa.google.com/" target="_blank">Picasa</a> on  a Windows.</p>
<h3>Step 3</h3>
<p>Let&#8217;s write some PHP. First we need to load the Zend classes.</p>
<pre>&lt;?php
&nbsp;
require_once &#039;Zend/Loader.php&#039;;
Zend_Loader::loadClass(&#039;Zend_Gdata&#039;);
Zend_Loader::loadClass(&#039;Zend_Gdata_ClientLogin&#039;);
Zend_Loader::loadClass(&#039;Zend_Gdata_Photos&#039;);
Zend_Loader::loadClass(&#039;Zend_Gdata_Photos_UserQuery&#039;);
</pre>
<h3>Step 4</h3>
<p>We write the PHP to grab the album feed.</p>
<pre>
function processPageLoad() 
{
&nbsp;&nbsp;// Parameters for ClientAuth authentication
&nbsp;&nbsp;$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
&nbsp;&nbsp;$user = &quot;username&quot;;
&nbsp;&nbsp;$pass = &quot;password&quot;;
&nbsp;
&nbsp;&nbsp;// Create an authenticated HTTP client
&nbsp;&nbsp;$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
&nbsp;
&nbsp;&nbsp;$photos = new Zend_Gdata_Photos($client);
&nbsp;
&nbsp;&nbsp;$query = new Zend_Gdata_Photos_UserQuery();
&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setUser($user);
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;// set num of columns
&nbsp;&nbsp;$columns = 3 ;
&nbsp;&nbsp;// counter used to determine whether to end row
&nbsp;&nbsp;$i = 0 ;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// crop albmun thumbnail img to 72px
&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setThumbsize(&quot;72c&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;$query-&gt;setMaxResults(9);
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;$userFeed = $photos-&gt;getUserFeed(null, $query);
&nbsp;&nbsp;&nbsp;&nbsp;$numResults = $userFeed-&gt;getTotalResults()-&gt;text;
</pre>
<h3>Step 5</h3>
<p>Write the PHP to display the albums.</p>
<pre>
&lt;?php 
&nbsp;&nbsp;echo &quot;&lt;table border=&#039;0&#039;&gt;\n&quot;;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;foreach ($userFeed as $entry) 
&nbsp;&nbsp;{
&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;if( $i % $columns == 0) 
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//if there is no remainder, we want to start a new row
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;tr&gt;\n&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp; 
&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;if ($entry instanceof Zend_Gdata_Photos_AlbumEntry) 
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;\t&lt;td&gt;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$var = ($i % $columns);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;a href=&#039;gallery.php?albumId=&quot;. $entry-&gt;getGphotoId();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&#039;&gt;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$thumb = $entry-&gt;getMediaGroup()-&gt;getThumbnail();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;img alt=&#039;pic&#039; class=&#039;galleryimg&#039; src=&#039;&quot; . $thumb[0]-&gt;getUrl() . &quot;&#039; /&gt;&lt;br /&gt;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/a&gt;&lt;/td&gt;&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;if( ($i % $columns) == ( $columns - 1) || ($i + 1) == $numResults) 
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/tr&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;$i ++ ;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;echo &quot;&lt;/table&gt;&quot;;&nbsp;&nbsp;
}
&nbsp;
}
?&gt;
</pre>
<h3>Step 6</h3>
<p>All that is left is to call the function where you want to display the albums.</p>
<pre>
&lt;?php
&nbsp;&nbsp;processPageLoad();
?&gt;
</pre>
<h3>Conclusion</h3>
<p>Now that wasn&#8217;t too difficult was it. Thanks Google. Next time I will be showing you how access the pictures in each of the albums. In the meantime <a href='wp-content/uploads/2008/10/picasa-albumsphp.zip'>download</a> the complete code and if you have any questions or comments please let me know. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nakunakifi.com/2008/10/how-to-integrate-google-picasa-into-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
