<?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>.larre &#187; howto</title> <atom:link href="http://www.larre.com/category/howto/feed/" rel="self" type="application/rss+xml" /><link>http://www.larre.com</link> <description>technology, innovation and media</description> <lastBuildDate>Fri, 29 Jan 2010 21:26:46 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.8.6</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Amazon S3 and CloudFront with Wordpress and DreamHost</title><link>http://www.larre.com/2010/01/24/amazon-s3-and-cloudfront-with-wordpress-and-dreamhost/</link> <comments>http://www.larre.com/2010/01/24/amazon-s3-and-cloudfront-with-wordpress-and-dreamhost/#comments</comments> <pubDate>Sun, 24 Jan 2010 22:56:49 +0000</pubDate> <dc:creator>larre</dc:creator> <category><![CDATA[Technology]]></category> <category><![CDATA[howto]]></category> <category><![CDATA[amazon]]></category> <category><![CDATA[amazon cloudfront]]></category> <category><![CDATA[amazon s3]]></category> <category><![CDATA[cloud]]></category> <category><![CDATA[cloudfront]]></category> <category><![CDATA[dreamhost]]></category> <category><![CDATA[s3]]></category> <category><![CDATA[wordpress]]></category><guid
isPermaLink="false">http://www.larre.com/?p=418</guid> <description><![CDATA[For the last couple of days I have been testing out the Amazon CloudFront service using my blog as a sandbox. My goal was pretty simple: To set up Amazon CloudFront on my blog, enabling static files like images and styles to be distributed for fast access. This post describes my experimentation with it. It [...]]]></description> <content:encoded><![CDATA[<div
id="attachment_459" class="wp-caption alignleft" style="width: 174px"><img
class="size-full wp-image-459" title="aws_logo" src="http://static.larre.com/blog/wp-content/uploads/2010/01/aws_logo.gif" alt="Amazon web services" width="164" height="60" /><p
class="wp-caption-text">Amazon web services</p></div> For the last couple of days I have been testing out the Amazon CloudFront service using my blog as a sandbox. My goal was pretty simple: To set up Amazon CloudFront on my blog, enabling static files like images and styles to be distributed for fast access. This post describes my experimentation with it. It is not just straight forward work, and there are different approaches you may choose among. So I thought I should write a short walk through of the steps that I have taken. If you wonder what Amazon CloudFront is, or looking for information on how it could be used in conjunction with Wordpress this post can give you an overview and help you getting started.</p><p>Let&#8217;s start with <a
href="http://en.wikipedia.org/wiki/Amazon_CloudFront">Amazon CloudFront</a> and what this actually is. CloudFront is a Content Distribution Network (CDN). The service distributes your data out to multiple datacenter locations, ensuring faster access times. It works together with another service from Amazon S3 (Simple Storage Service). <a
href="http://en.wikipedia.org/wiki/Amazon_S3">Amazon S3</a> is a data storage service where your files is stored initially. To be using CloudFront for distribution you need to have a S3 account and store the files there.</p><p><strong>Setting up an Amazon Web Services account</strong><br
/> <a
href="http://www.larre.com/2009/01/19/jungledisk-amazon-s3-and-contentie5/">As I have blogged about before</a>, I use Amazon S3 already, so it was not necessary for me to create an Amazon Web Services account. If you do not have an Amazon Web Services account <a
href="http://aws.amazon.com/">head over here to register</a>. After you have registered, you must enable both the <a
href="http://aws.amazon.com/s3/">Amazon S3 service</a> and the <a
href="http://aws.amazon.com/cloudfront/">Amazon CloudFront service</a> to your account (just follow the links and sign up).</p><p>With an AWS account and enabled both S3 and CloudFront to this account I was ready to start experimenting. Amazon Web Services is just services. This means that they only offers their services via APIs. Uploading a file to your S3 account must be done by a client. If you are a programmer it&#8217;s easy to just develop a client, but there are a lot of clients/programs around. An easy and simple client is <a
href="http://www.s3fox.net/">S3Fox</a>, a Firefox extension that that lets you upload files to Amazon S3 and manage the files&#8217; access control. I use <a
href="http://s3browser.com/">S3 Browser</a>, a great application that handles the administration of my S3 files. Using S3Fox or S3 Browser makes it easy to test the S3 and CloudFront account, making sure it works. Objects (or files) are organized into buckets that can be created, listed, and retrieved using either a REST-style HTTP interface or a SOAP interface.</p><p>The first thing I had to do was to grab the AWS Access Key and the AWS Secret Access Key. Log in to the AWS account and click on &#8216;Security Credentials&#8217; in the left menu. The first thing I did was to set up the S3 Browser account with this Access Key and Secret Key. I created my bucket and named it &#8216;<em>static.larre.com</em>&#8216;, then uploaded some files to be sure everything worked:<br
/><div
id="attachment_485" class="wp-caption alignnone" style="width: 610px"><a
href="http://static.larre.com/blog/wp-content/uploads/2010/01/s3-test.jpg"><img
src="http://static.larre.com/blog/wp-content/uploads/2010/01/s3-test1.jpg" alt="Testing S3 bucket" title="s3 test" width="600" height="326" class="size-full wp-image-485" /></a><p
class="wp-caption-text">Testing S3 bucket</p></div><p><strong>Setting up CloudFront for my WordPress blog</strong><br
/> Now I had an Amazon Web Services account, enabled Amazon S3, installed S3 Browser, created a bucket named &#8217;static.larre.com&#8217;,  and uploaded files to this bucket. So far so good. Time to concentrate on the Amazon CloudFront and how to integrate it into my blog, that runs WordPress. There are several approaches that can be used. I have tried a couple of different approaches that I&#8217;ll try to describe.</p><p><em>Using Dreamhost</em><br
/> Besides hilarious monthly newsletters DreamHost is a great web hosting company. I use DreamHost for hosting of this blog. Last year DreamHost integrated CloudFront into their hosting service. A pretty <a
href="http://blog.dreamhost.com/2009/03/16/cgn-vs-cdn/">amusing blog post from DreamHost about it is here</a>. With CloudFront as a &#8220;Goodie-service&#8221; smoothly integrated in my hosting environment it is really simple to get started. The step is to create a cloudfront domain filling out this form:<br
/><div
id="attachment_492" class="wp-caption alignnone" style="width: 610px"><a
href="http://static.larre.com/blog/wp-content/uploads/2010/01/dreamhost-cloudfront.jpg"><img
src="http://static.larre.com/blog/wp-content/uploads/2010/01/dreamhost-cloudfront2.jpg" alt="CloudFront Domain" title="dreamhost cloudfront" width="600" height="171" class="size-full wp-image-492" /></a><p
class="wp-caption-text">CloudFront Domain</p></div></p><p>What it does is to create a directory where you can put all files and directories that is going to be stored at S3 and distributed by CloudFront. A very simple admin view where you can handle simple tasks like delete, rescan etc is also part of this &#8220;goodies&#8221; service. When creating the CloudFront Domain, DreamHost creates a distribution for you at Amazon CloudFront. A distribution specifies the location of the original version of your objects. A distribution has a unique CloudFront.net domain name that you can use to reference your objects through the network of edge locations. If you wish, you can also map your own domain name to your distribution. DreamHost adds a CNAME record (in this case it was &#8217;static&#8217;), that has the cloudfront.net address as value. Using a CNAME enables me to use a domain name (in this case static.larre.com) instead of the domain name CloudFront provides. So looking at my own CloudFront distribution I have the following:</p><ul><li>http://static.larre.com (my own mapped domain to the distribution)</li><li>http://d20o1nml9my7kd.cloudfront.net (the unique cloudfront.net domain)</li><li>http://static.larre.com.s3.amazonaws.com (the origin bucket at S3)</li></ul><p>One of the most annoying thing about this service, is the lag from I request a rescan until my files are uploaded to S3. During the test period for the last couple of days it has taken everything from 10 minutes to several hours before DreamHost actually did rescan and upload/delete files in my S3 bucket. When DreamHost had finished scanning the directory and uploaded the files to S3, they where accessible. It seems that the only way to upload files is to do it manually within the DreamHost Admin Panel.</p><p>Using the service from Dreamhost may be a bit simple and manually copying all the needed files to the specified directory is not a very elegant solution. A more scalable solution is to make some scripts and jobs that pretty much does the work for you. <a
href="http://www.morphatic.com/2009/07/21/optimizing-wordpress-with-my-cdn/">Here is a blog post</a> that describes one solution to make scripts and jobs for copying static files from Dreamhost to Cloudfront.</p><p><em>Adding a Wordpress plugin</em><br
/> To work with my CloudFront Domain (http://static.larre.com), I tested a simple Wordpress Plugin: &#8216;My CDN&#8217;. This plugin help you offloading javascript, css and theme files to your own CDN network, but only handle url rewriting not actual file transferring. Installing the plugin, activating it, and then adding three input fields under the settings section, was pretty much what I had to do (<a
href="http://static.larre.com/blog/wp-content/uploads/2010/01/my-cdn-settings1.jpg">here is a screenshot of the settings page</a>). One of the problems with this setup and solution, is that I have to manually put files in the specific directory (as described under the DreamHost section) unless I write a bunch of script-code. I think a better solution is to develop or find an already developed plugin that handles the prefixing of static content and also the upload to S3.</p><p>I&#8217;ve found one plugin: <a
href="http://www.w3-edge.com/wordpress-plugins/w3-total-cache/">W3 Total Cache</a> developed by <a
href="http://www.linkedin.com/in/w3edge">Frederick Townes</a> It&#8217;s a plugin improving the user experience of your blog by adding page caching, database caching, minify, content delivery network (CDN) functionality and more. Late last year they implemented integration with AWS and CloudFront. I have used the <a
href="http://ocaoimh.ie/wp-super-cache/">WP Super Cache</a> until now, but it&#8217;s necessary to deactivate it before trying to install and activating the W3 Total Cache.  Setting up this plugin is straight forward. After installing the plugin and activated it, I rolled over to the settings sections. First of all I had to activate the CDN and chose Amazon CloudFront as the CDN Type. Under the CDN settings I had to enter my Access Key, Secret Key, bucket and CNAME:</p><div
id="attachment_448" class="wp-caption alignnone" style="width: 610px"><img
class="size-full wp-image-448" title="cdn settings2" src="http://static.larre.com/blog/wp-content/uploads/2010/01/cdn-settings2.jpg" alt="cdn settings" width="600" height="218" /><p
class="wp-caption-text">cdn settings</p></div><p>The plugin makes it easy to upload whatever static content you have on your WordPress blog to CloudFront. In the settings sections you specify extensions and files for upload to S3. During the testing period (a couple of days) I have found one issue with this plugin.  I use <a
href="http://www.bravenewcode.com/products/wptouch/">WPtouch</a>. It is a mobile theme, that automatically transforms your WordPress blog into a web-application experience when viewed from an iPhone, iPod touch, Android, or BlackBerry Storm touch mobile device. The default settings for W3 Total Cache captured the mobile devices and bypassed WPtouch. I solved it by adding mobile user agents in the corresponding field under the settings for page cache, minify and CDN.</p><p>As far as I can see, the DreamHost integration is not the solution for integrating my Wordpress blog with Amazon CloudFront. With other needs than to get static WP content out to the edges it may be a nice functionality. But probably you will have to write some scripts and batch jobs working with the CloudFront directory before you get an elegant and effective solution. The W3 Total Cache plugin seems to be an easy and effective tool to use for mye goal. Setting up an AWS account, enabling S3 and CloudFront and adding a CNAME record is what you have to do before working with the plugin. Everything else seems to be achievable within the settings section.</p><p>Everything that is referenced with http://static.larre.com is now hosted by Amazon S3 and distributed out by Amazon CloudFront services.</p> ]]></content:encoded> <wfw:commentRss>http://www.larre.com/2010/01/24/amazon-s3-and-cloudfront-with-wordpress-and-dreamhost/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Jungle Disk, Amazon S3 and Content.IE5</title><link>http://www.larre.com/2009/01/19/jungledisk-amazon-s3-and-contentie5/</link> <comments>http://www.larre.com/2009/01/19/jungledisk-amazon-s3-and-contentie5/#comments</comments> <pubDate>Mon, 19 Jan 2009 12:25:29 +0000</pubDate> <dc:creator>larre</dc:creator> <category><![CDATA[comment]]></category> <category><![CDATA[howto]]></category> <category><![CDATA[amazon]]></category> <category><![CDATA[amazon s3]]></category> <category><![CDATA[jungle disk]]></category> <category><![CDATA[jungledisk]]></category> <category><![CDATA[simple storage system]]></category><guid
isPermaLink="false">http://www.larre.com/?p=184</guid> <description><![CDATA[I have been using Amazon S3 with Jungle Disk as a Client for the last couple of years. This is a great solution though the cost is pretty high if you compare it to just buying an external disk.
What is Amazon S3, and Jungle Disk
Amazon S3 provides a simple web services interface that can be [...]]]></description> <content:encoded><![CDATA[<p>I have been using Amazon S3 with Jungle Disk as a Client for the last couple of years. This is a great solution though the cost is pretty high if you compare it to just buying an external disk.</p><p><strong>What is Amazon S3, and Jungle Disk</strong><br
/> <a
href="http://aws.amazon.com/s3/">Amazon S3</a> provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. I use it to backup all my digital contents (music, photo, video). Amazon S3 does not offer any type of clients to typically access the service just a set of API’s. I first started out with implementing my own client but found out that writing my own client is just too geeky. I use <a
href="http://jungledisk.com/">Jungle Disk</a> as a client to access my S3 account. This combination works perfect and I’m really happy with both S3 and Jungle Disk.</p><p><strong>The problem with Content.IE5</strong><br
/> I have not set up automatic backup but make a backup manually by copying folders from my network drive and over to my S3 account. Jungle Disk maps a drive to my Amazon S3 account for seamless integration. And here is where the problem or issue comes into action. What happens is that for each file that I copy from my local storage (read network drive) to my S3 area the file is temporarily stored at my local PC at:</p><p><em>C:\Documents and Settings\LocalService\Local Settings\Temporary Internet Files\Content.IE5</em></p><p>This folder is actually a hidden one (system folder) and not easy accessible for non-tech persons. I found out about this because my local drive almost got out of free space. This hidden temporarily folder was eating up my local Gigabytes.</p><p><strong>The solution to the problem with Content.IE5</strong><br
/> The solution to this problem is of course to delete the directories and files that are stored in this temporarily directory. This can be done manually or you could write a batch file that is executed after you have backed up files. This is what I have done.</p><p>Another solution is looking more into what is causing the local storage (caching). The problem is that Jungle Disk is running in the environment of the Local Service user. The files will be stored until the Local Service user reaches the cache limit. Her is a nice <a
href="http://forum.jungledisk.com/viewtopic.php?t=1378">thread</a> describing some of this issues. The solution is to ensure a cache limit that is small (or not extremely large) so that the system will clean up nicely. If we look at the solution described in the thread it describes where to set this limit in the registry. Using <em>regedit</em> I checked what the CacheLimit on my PC was: 256 MB. This is way lower than the 15 GB I had to delete the first time I found out of the the Content.IE5 folder issue.</p><p>I do not think this solution will work. I think that the Local Service is running under some other user (WindowsNT user?). But this is just a wild guess. Another issue is that to change the registry for the Local Service all processes by that user must be shut down. This could be a bit tricky, but most of all, it’s time consuming trying to find out what will work or not.</p><p>So I still run a manual clean of the Content.IE5 folder…</p> ]]></content:encoded> <wfw:commentRss>http://www.larre.com/2009/01/19/jungledisk-amazon-s3-and-contentie5/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>How to organize my iPhone</title><link>http://www.larre.com/2008/09/25/how-to-organize-my-iphone/</link> <comments>http://www.larre.com/2008/09/25/how-to-organize-my-iphone/#comments</comments> <pubDate>Thu, 25 Sep 2008 19:42:26 +0000</pubDate> <dc:creator>larre</dc:creator> <category><![CDATA[comment]]></category> <category><![CDATA[howto]]></category> <category><![CDATA[iPhone]]></category> <category><![CDATA[iphone 3G]]></category> <category><![CDATA[organizing]]></category><guid
isPermaLink="false">http://www.larre.com/?p=35</guid> <description><![CDATA[ After using my iPhone 3G for some time now, I find my self confused when it comes to organizing all my applications. At first glance the look &#38; and feel of the iPhone was great, but now I tend to think that Apple sure has forgotten something important. When you estimate to sell billions [...]]]></description> <content:encoded><![CDATA[<p><img
hspace="10" align="left" src="http://static.larre.com/blog/wp-content/uploads/2008/09/photo-150x150.jpg" alt="My front page" /> After using my <a
href="http://www.apple.com/iphone/features/wireless.html">iPhone 3G</a> for some time now, I find my self confused when it comes to organizing all my applications. At first glance the look &amp; and feel of the iPhone was great, but now I tend to think that <a
href="http://www.apple.com">Apple</a> sure has forgotten something important. When you estimate to sell billions of applications it should be clear that the average user will have a lot of them on their phone, and along comes the issue.</p><p><br/>How well is the user interface when the user has 55 apps (as I have at the time this post is written)?. There are some factors to take into account:</p><ul><li>Native iPhone apps</li><li>Third party apps</li><li>Your own apps (could go as third party)</li><li>Native apps in regular use</li><li>Third party apps in regular use</li><li>Third party apps for testing purpose</li><li>Different categories like games, travel, office etc</li><li>&#8230; (and more)</li></ul><p>My experience is that if you put 16 applications in one page it&#8217;s a mess everytime you are looking for one; It&#8217;s impossible to find it. And if the application is not on the front page&#8230; where is it? On page 4&#8230;5? By using some of the factores above I have organized my iPhone to some extent, but sure would like to see Apple develop some great and innovative user interface that will work better than it does today. After organizing all my applications I found my self often slide over to the last page. Suddenly I was using the games more regular than first thought. If you know how to move an entire page at a time, please let me know (without using the jailbreaked Categories app). This is actually an extremely time-consuming process.</p><p>So, here is how I organized my iPhone:</p><ol><li>What I did was to put Native and third party applications that I use often on my front page limiting them to 12.</li><li>On my second page I put all the native and third party apps that I use by regular basis.</li><li>On my third page is all my applications that supports me when I&#8217;m out traveling.</li><li>On my forth page is all my games.</li><li>On my fifth page I have the applications rarely in use</li><li>And the last one is for temporarily testing purpose.</li></ol><p><strong>UPDATE:</strong>Today I came over this nice post that is digging more into the issues in this post. Also.. 9 pages maximum?? I still have 2 pages until I will have trouble: <a
href="http://venturebeat.com/2008/12/21/the-need-for-iphone-app-folders-and-search-is-quickly-approaching/">http://venturebeat.com/2008/12/21/the-need-for-iphone-app-folders-and-search-is-quickly-approaching/</a></p> ]]></content:encoded> <wfw:commentRss>http://www.larre.com/2008/09/25/how-to-organize-my-iphone/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>AirPort Express audio drop out &#8211; how I solved it.</title><link>http://www.larre.com/2008/01/10/airport-express-and-audio-drop-out-how-i-solved-it/</link> <comments>http://www.larre.com/2008/01/10/airport-express-and-audio-drop-out-how-i-solved-it/#comments</comments> <pubDate>Thu, 10 Jan 2008 23:08:27 +0000</pubDate> <dc:creator>larre</dc:creator> <category><![CDATA[comment]]></category> <category><![CDATA[howto]]></category> <category><![CDATA[airport]]></category> <category><![CDATA[airport express]]></category> <category><![CDATA[audio]]></category> <category><![CDATA[audio drop out]]></category> <category><![CDATA[drop out]]></category> <category><![CDATA[dropout]]></category> <category><![CDATA[express]]></category><guid
isPermaLink="false">http://larre.wordpress.com/2008/01/10/airport-express-and-audio-drop-out-how-i-solved-it/</guid> <description><![CDATA[ At the end of 2007 I found my old AirPort Express. Looking down on it I remembered why I put it away; Audio Drop Out. What a big mistake buying that thing. Well, I desided that I had to use some time to solve the problem and start using this fantastic nice gadget.
The first [...]]]></description> <content:encoded><![CDATA[<p><img
hspace="10" align="left" src="http://larre.files.wordpress.com/2008/01/airportexpress_edited1.thumbnail.jpg" alt="AirPort Express" /> At the end of 2007 I found my old AirPort Express. Looking down on it I remembered why I put it away; Audio Drop Out. What a big mistake buying that thing. Well, I desided that I had to use some time to solve the problem and start using this fantastic nice gadget.</p><p><br/>The first thing I did was to look into the information at Apple&#8217;s own site to see if they had written anything about this issue. And yes, they have.  a firmware update should solve the issue (<a
href="http://www.apple.com/ca/downloads/macosx/apple/firmware_hardware/airportexpressfirmwareupdate63forwindows.html">firmware update</a>)&#8230; BUT it did not.</p><p>So I had to search the net to look for help. Whow, it seems that a lot of people is  experiencing  this problem. There is a lot of fancy and odd solutions and I tried everything I ever came over:</p><ul><li>Firmware Update</li><li>Changing wlan channel</li><li>Using network robustness</li><li>Moving microwaves and wireless phones around</li><li>Upgraded the network from 802.11b to 802.11g</li><li>Using multiple speakers</li><li>and more&#8230;</li></ul><p>Here are some links:</p><ul><li><span
class="articleText"><a
href="http://docs.info.apple.com/article.html?artnum=108065">Apples list of actions</a></span></li><li><span
class="articleText"><a
href="http://www.macfixit.com/article.php?story=20040803083904758">802.11b/802.11g</a></span></li><li><span
class="articleText"><a
href="http://forums.macnn.com/92/networking/327105/airtunes-drop-intermittently/">IP phone, Microwave</a></span></li><li><span
class="articleText"><a
href="http://www.macosxhints.com/article.php?story=20060512044141904">Multiple speakers</a></span></li></ul><p>Nothing helped. So I then had to figure out what actually happend with my computer during the drop out. I looked at 2 things; Network traffic and CPU usage. What I found out whas that the network traffic was ok, nothing odd with it. But, when I looked at CPU usage, I found one correlation with the drop out. Whenever my computer was working or had a CPU usage that was more than typically a couple of %, I got a drop out.</p><p>So, what did I do?</p><p>When streaming music to my AirPort Express I shut down all other applications, typically MSN, Firefox, Word etc.  This solved the problem. No drop outs.</p><p>My conclusion is that there is no problem with the AirPort Express, the problem is related to the client that streams.  AirPort Express drop out is not a problem for me anymore I just have to focus on the music not doing a lot of things at the same time <img
src='http://static.larre.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://www.larre.com/2008/01/10/airport-express-and-audio-drop-out-how-i-solved-it/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>Building a Facebook Application in 15 minutes</title><link>http://www.larre.com/2007/10/10/building-a-facebook-application-in-15-minutes/</link> <comments>http://www.larre.com/2007/10/10/building-a-facebook-application-in-15-minutes/#comments</comments> <pubDate>Wed, 10 Oct 2007 09:29:07 +0000</pubDate> <dc:creator>larre</dc:creator> <category><![CDATA[howto]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[app]]></category> <category><![CDATA[application]]></category> <category><![CDATA[code]]></category> <category><![CDATA[development]]></category> <category><![CDATA[facebook]]></category> <category><![CDATA[integration]]></category> <category><![CDATA[java]]></category> <category><![CDATA[jsp]]></category> <category><![CDATA[platform]]></category><guid
isPermaLink="false">http://larre.wordpress.com/2007/10/10/building-a-facebook-application-in-15-minutes/</guid> <description><![CDATA[So, after fowa and 90k+ developers in mind, I just had to go ahead and implement a Facebook application. Here is the code and how I implemented it.
See also: Reflections after having implemented Facebook Connect and Google Friend Connect on my blog
First of all my goal was to use an existing web application, write a [...]]]></description> <content:encoded><![CDATA[<p>So, after <a
href="http://www.larre.com/2007/10/09/future-of-web-apps/">fowa</a> and 90k+ developers in mind, I just had to go ahead and implement a Facebook application. Here is the code and how I implemented it.</p><p><strong>See also: <a
href="http://www.larre.com/2008/12/18/reflections-after-having-implemented-facebook-connect-and-google-friend-connect-on-my-blog/">Reflections after having implemented Facebook Connect and Google Friend Connect on my blog</a></strong></p><p>First of all my goal was to use an existing web application, write a facebook integration module that communicates with the Facebook APIs, extracting some information/data and presenting them inside the existing web application. The web application I used is based on a j2ee framework (jsp, java). The architecture is much like <a
href="http://struts.apache.org">Struts</a> The first thing to do was to <a
href="http://developers.facebook.com/get_started.php">get the Developer Application</a> to my existing Facebook account. Then I had to download the <a
href="http://developers.facebook.com/resources.php">Client Library</a>. I choosed the Java Library since my development environment was Java. When I extracted the Client Library, only the source files where included. So what I had to do first (besides looking into the source code), was to compile the java-files. I actually wrote an ant-task for this purpose, but a more easier way is just to use javac without using ant-framework. The next step was to take the output from the compile process and put it into an archived file (.jar). This is not necessary but I like to do it this way and the facebook.jar file I now had is easily dropped into my existing web application library. In my Facebook profile I had to create (set up) a new application. This is done by clicking the developer application that was installed earlier. Its some steps including getting a key (API key and secret key) that I used in my java-code but this process is straight forward.</p><p
align="left">Ok, now lets start the coding process. Here is the java code controlling the session and authentication:</p><p
align="left"><em>String apiKey = &#8220;something&#8221;;<br
/> String secretKey = &#8220;something&#8221;; </em></p><p
align="left"><em>FacebookRestClient frc = null;<br
/> HttpSession session = request.getSession();<br
/> String sessionKey = (String) session.getAttribute(&#8221;facebookSession&#8221;);<br
/> String token = request.getParameter(&#8221;auth_token&#8221;);</em></p><p
align="left"><em>try {</em></p><p
align="left"><em>if (sessionKey != null &amp;&amp; sessionKey.length() &gt; 0) {</em></p><p
align="left"><em>frc = new FacebookRestClient(apiKey, secretKey, sessionKey);<br
/> this.doTheThing(request, response, frc);<br
/> } else if (token != null) {<br
/> frc = new FacebookRestClient(apiKey, secretKey);<br
/> session.setAttribute(&#8221;facebookSession&#8221;, sessionKey);<br
/> sessionKey = frc.auth_getSession(token);<br
/> session.setAttribute(&#8221;facebookSession&#8221;, sessionKey);<br
/> this.doTheThing(request, response, frc);<br
/> </em></p><p
align="left"><em>} else {<br
/> response.sendRedirect(&#8221;http://www.facebook.com/login.php?api_key=&#8221; + apiKey + &#8220;&amp;v=1.0&#8243;);<br
/> }<br
/> } catch (FacebookException fe) {<br
/> } catch (IOException ioe) {<br
/> &#8230;</em></p><p
align="left">The <em>doTheThing</em> method is extracting the information and looks like this:</p><p
align="left"><em>int myid = frc.users_getLoggedInUser();<br
/> EnumSet&lt;ProfileField&gt; fields = EnumSet.of(com.facebook.api.ProfileField.NAME, com.facebook.api.ProfileField.PIC, com.facebook.api.ProfileField.PIC_BIG, com.facebook.api.ProfileField.PIC_SMALL);<br
/> Collection&lt;Integer&gt; users = new ArrayList();<br
/> users.add(myid);</em></p><p><em>// Get my information<br
/> Document d = frc.users_getInfo(users, fields);<br
/> String myname = d.getElementsByTagName(&#8221;name&#8221;).item(0).getTextContent();<br
/> String mypicture = d.getElementsByTagName(&#8221;pic&#8221;).item(0).getTextContent();</em></p><p><em>// Get my friends id<br
/> Document d2 = frc.friends_get();<br
/> String s = d2.toString();<br
/> NodeList userIDNodes = d2.getElementsByTagName(&#8221;uid&#8221;);<br
/> int fcount = userIDNodes.getLength();</em></p><p><em>Collection&lt;Integer&gt; friends = new ArrayList&lt;Integer&gt;();<br
/> for (int i = 0; i &lt; fcount; i++) {<br
/> Node node = userIDNodes.item(i);<br
/> String idText = node.getTextContent();<br
/> Integer id = Integer.valueOf(idText);<br
/> friends.add(id);<br
/> }</em></p><p><em>List l = new ArrayList();<br
/> Map m = new HashMap();<br
/> Document d3 = frc.users_getInfo(friends, fields);</em></p><p>// Get my friends information<br
/> for (int j = 0; j &lt; fcount; j++) {<br
/> String name2 = d3.getElementsByTagName(&#8221;name&#8221;).item(j).getTextContent();<br
/> String picture2 = d3.getElementsByTagName(&#8221;pic&#8221;).item(j).getTextContent();<br
/> String picture3 = d3.getElementsByTagName(&#8221;pic_small&#8221;).item(j).getTextContent();<br
/> String picture4 = d3.getElementsByTagName(&#8221;pic_big&#8221;).item(j).getTextContent();</p><p><em>m.put(&#8221;name&#8221;, name2);<br
/> m.put(&#8221;picture&#8221;, picture2);<br
/> m.put(&#8221;picture_small&#8221;, picture3);<br
/> m.put(&#8221;picture_big&#8221;, picture4);</em></p><p><em>l .add(m);<br
/> m = new HashMap();</em></p><p><em>}<br
/> request.setAttribute(&#8221;friends&#8221;, l);<br
/> request.setAttribute(&#8221;myname&#8221;, myname);<br
/> request.setAttribute(&#8221;mypicture&#8221;, mypicture);<br
/> request.setAttribute(&#8221;numFriends&#8221;, new Integer(fcount));</em></p><p
align="left"><p
align="left">So all the information from Facebook is now added to the request and can be displayed in a JSP. The code above is not very elegant and is not optimized(!). Its just a pice of code done after half an hour of work and my goal was to implement an integration module for testing purpose.</p><p>Hope this blog post can help others looking for hints when getting started with Facebook application development/integration.</p> ]]></content:encoded> <wfw:commentRss>http://www.larre.com/2007/10/10/building-a-facebook-application-in-15-minutes/feed/</wfw:commentRss> <slash:comments>33</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk
Group:              category
-->

<!-- W3 Total Cache: CDN debug info:
Engine:             cf
Replaced URLs:
http://www.larre.com/blog/wp-content/uploads/2010/01/aws_logo.gif
http://www.larre.com/blog/wp-content/uploads/2010/01/s3-test.jpg
http://www.larre.com/blog/wp-content/uploads/2010/01/s3-test1.jpg
http://www.larre.com/blog/wp-content/uploads/2010/01/dreamhost-cloudfront.jpg
http://www.larre.com/blog/wp-content/uploads/2010/01/dreamhost-cloudfront2.jpg
http://www.larre.com/blog/wp-content/uploads/2010/01/my-cdn-settings1.jpg
http://www.larre.com/blog/wp-content/uploads/2010/01/cdn-settings2.jpg
http://www.larre.com/blog/wp-content/uploads/2008/09/photo-150x150.jpg
http://www.larre.com/blog/wp-includes/images/smilies/icon_smile.gif
-->

<!-- W3 Total Cache: Db cache debug info:
Engine:             disk
Total queries:      14
Cached queries:     0
Total query time:   0.031
SQL info:
    # | Time (s) |    Caching (Reject reason)     |   Status   | Query
    1 |    0.014 |            enabled             | Not cached | SELECT option_name, option_value FROM wp_nj5ugn_options WHERE autoload = 'yes'
    2 |    0.002 |            enabled             | Not cached | SELECT option_value FROM wp_nj5ugn_options WHERE option_name = 'aiosp_post_title_format' LIMIT 1
    3 |    0.002 |            enabled             | Not cached | SELECT option_value FROM wp_nj5ugn_options WHERE option_name = 'openid_associations' LIMIT 1
    4 |    0.001 |            enabled             | Not cached | SELECT option_value FROM wp_nj5ugn_options WHERE option_name = 'openid_nonces' LIMIT 1
    5 |    0.001 |            enabled             | Not cached | SELECT post_modified_gmt FROM wp_nj5ugn_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1
    6 |    0.001 |            enabled             | Not cached | SELECT post_date_gmt FROM wp_nj5ugn_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date_gmt DESC LIMIT 1
    7 |    0.001 |            enabled             | Not cached | SELECT t.*, tt.* FROM wp_nj5ugn_terms AS t INNER JOIN wp_nj5ugn_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category')  AND t.slug = 'howto' ORDER BY t.name ASC
    8 |    0.004 |  disabled (query is rejected)  | Not cached | SELECT SQL_CALC_FOUND_ROWS  wp_nj5ugn_posts.* FROM wp_nj5ugn_posts  INNER JOIN wp_nj5ugn_term_relationships ON (wp_nj5ugn_posts.ID = wp_nj5ugn_term_relationships.object_id) INNER JOIN wp_nj5ugn_term_taxonomy ON (wp_nj5ugn_term_relationships.term_taxonomy_id = wp_nj5ugn_term_taxonomy.term_taxonomy_id)  WHERE 1=1  AND wp_nj5ugn_term_taxonomy.taxonomy = 'category' AND wp_nj5ugn_term_taxonomy.term_id IN ('13') AND wp_nj5ugn_posts.post_type = 'post' AND (wp_nj5ugn_posts.post_status = 'publish') GROUP BY wp_nj5ugn_posts.ID ORDER BY wp_nj5ugn_posts.post_date DESC LIMIT 0, 10
    9 |    0.001 |  disabled (query is rejected)  | Not cached | SELECT FOUND_ROWS()
   10 |    0.002 |            enabled             | Not cached | SELECT t.*, tt.*, tr.object_id FROM wp_nj5ugn_terms AS t INNER JOIN wp_nj5ugn_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_nj5ugn_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag') AND tr.object_id IN (418, 184, 35, 17, 15) ORDER BY t.name ASC
   11 |    0.002 |            enabled             | Not cached | SELECT post_id, meta_key, meta_value FROM wp_nj5ugn_postmeta WHERE post_id IN (418,184,35,17,15)
   12 |    0.002 |            enabled             | Not cached | SELECT * FROM wp_nj5ugn_users WHERE ID = 2 LIMIT 1
   13 |    0.002 |            enabled             | Not cached | SELECT meta_key, meta_value FROM wp_nj5ugn_usermeta WHERE user_id = 2
   14 |    0.001 |            enabled             | Not cached | SELECT remote_path FROM wp_nj5ugn_w3tc_cdn_queue
-->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk
Key:                w3tc_99f03baef0ec9a5cf935256f33dc9796_page_c7c7c44d218706f6b10fe7a3c50eb581
Caching:            disabled
Reject reason:      user agent is rejected
Status:             not cached
Creation Time:      0.671s
Header info:
X-Powered-By:       W3 Total Cache/0.8.5.1
Expires:            Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control:      no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma:             no-cache
X-Pingback:         http://www.larre.com/blog/xmlrpc.php
Last-Modified:      Fri, 29 Jan 2010 21:26:46 GMT
ETag:               "794e7f11c619555748c1fbcd485532dd"
Content-Type:       text/xml; charset=UTF-8
-->