Using Google Picasa Inside CodeIgniter

4,789 views

Published on

Small tutorial on how to use the Google Data API with CodeIgniter

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,789
On SlideShare
0
From Embeds
0
Number of Embeds
39
Actions
Shares
0
Downloads
68
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Using Google Picasa Inside CodeIgniter

  1. 1. Using Google Picasa inside CodeIgniter<br />
  2. 2. Content<br />What will you need<br />Getting everything<br />Installing everything<br />The controller<br />The view page<br />
  3. 3. What will we need<br />Apache+PHP 4.0<br />CodeIgniter<br />Zend library for Google Data API<br />
  4. 4. Getting everything<br />For Apache+PHP download Wamp from http://www.wampserver.com/en/<br />Download the CodeIgniter framework from http://codeigniter.com/downloads/<br />Do use the Google Data API download http://framework.zend.com/download/gdata/<br />
  5. 5. Setting up the libraries<br />Install Wamp in a directory on a local drive<br />Extract the content of the archive with the CodeIgniter framework.<br />Make a directory in the www folder from Wamp called codeigniter and copy there the content of the archive<br />Copy the content of the archive wich contains the Zend library for Google Data API and copy it to www/codeigniter/application/libraries<br />
  6. 6. Setting up the libraries<br />wwwcodeigniter folder should be like in the left picture:<br />wwwcodeignitersystem<br />applicationlibraries<br />end folder should be like <br />in the right picture:<br />
  7. 7. The controller<br />&lt;?php<br />class Picassa extends Controller { <br /> function Picassa(){ parent::Controller(); <br /> } <br /> function index()<br /> { <br /> $data[&apos;title&apos;]=&apos;Google Picasa example&apos;; $data[&apos;tag&apos;]=&apos;dog&apos;; <br /> $this-&gt;load-&gt;view(&apos;Picassa&apos;,$data); <br /> } <br /> }<br />?&gt;<br />Extindemclasa Controller din CodeIgniter<br />Setamdatele custom care vorfitrimise view-ului, in view vomavea o variabila $tag siuna $title cu valorilesetateaici<br />Incarcam view-ulnecesar<br />
  8. 8. The view<br />Avemacces la variabilasetata din controller<br />&lt;html&gt;<br /> &lt;head&gt;<br /> &lt;title&gt;&lt;?php echo $title; ?&gt; &lt;/title&gt;<br /> &lt;/head&gt;<br /> &lt;body&gt;<br /> &lt;?php<br />set_include_path(&quot;C:wampwwwcodeignitersystemapplicationlibraries&quot;);<br />require_once&apos;ZendLoader.php&apos;;<br />Zend_Loader::loadClass(&apos;Zend_Gdata_Photos&apos;);<br />Zend_Loader::loadClass(&apos;Zend_Gdata_ClientLogin&apos;);<br />Zend_Loader::loadClass(&apos;Zend_Gdata_AuthSub&apos;);<br />$gp = new Zend_Gdata_Photos(null,&quot;Google-DevelopersGuide-1.0&quot;);<br /> $query = $gp-&gt;newQuery(&quot;http://picasaweb.google.com/data/feed/api/all&quot;);<br />$query-&gt;setParam(&quot;kind&quot;, &quot;photo&quot;);<br />Spunem PHP-uluiundetrebuiesa se uitedupalibrarii<br />InitializamZendGdata API<br />
  9. 9. The view<br /> $query-&gt;setQuery($tag);<br />// maximum of 10 results<br />$query-&gt;setMaxResults(&quot;10&quot;);<br />$userFeed = $gp-&gt;getUserFeed(null, $query);<br />foreach($userFeed as $photoEntry) <br />{<br />echo &quot;&lt;p&gt;&quot;;<br />echo &quot;&lt;a href=&apos;&quot;.$photoEntry-&gt;getLink(&apos;alternate&apos;)-&gt;getHref() .&quot;&apos;&gt;Link album&lt;/a&gt;&lt;br /&gt; &quot;;<br />if ($photoEntry-&gt;getMediaGroup()-&gt;getContent() != null) <br />{<br /> $mediaContentArray = $photoEntry-&gt;getMediaGroup()-&gt;getContent();<br />$contentUrl = $mediaContentArray[0]-&gt;getUrl();<br />echo &quot;&lt;img style=&apos;width:300px;&apos; src=&apos;&quot;.$contentUrl.&quot;&apos;/&gt;&quot;;<br />}<br /> echo &quot;&lt;/p&gt;&quot;;<br />}<br />?&gt;<br /> &lt;/body&gt;<br />&lt;/html&gt;<br />Vomobtine maxim 10 poze in urmacautarii<br />Luam din variabila $tag textuldupa care facemcautarea<br />Luamurl-ulimaginii<br />

×