<?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>Cognition &#187; fql</title>
	<atom:link href="http://www.cognition.ca/tag/fql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cognition.ca</link>
	<description>Balls-in-the-air Entrepreneurship and Juggling.</description>
	<lastBuildDate>Tue, 14 Jun 2011 10:04:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Facebook Application Development How-to: 11 Tips You Don&#8217;t Want to Miss</title>
		<link>http://www.cognition.ca/2008/02/facebook-application-development-how-to-11-tips-you-dont-want-to-miss.html</link>
		<comments>http://www.cognition.ca/2008/02/facebook-application-development-how-to-11-tips-you-dont-want-to-miss.html#comments</comments>
		<pubDate>Thu, 28 Feb 2008 07:36:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[entrepreneurs]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook api]]></category>
		<category><![CDATA[facebook application development]]></category>
		<category><![CDATA[facebook apps]]></category>
		<category><![CDATA[fbml]]></category>
		<category><![CDATA[fql]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.cognition.ca/2008/02/facebook-application-development-how-to-11-tips-you-dont-want-to-miss.html</guid>
		<description><![CDATA[I&#8217;ve built several facebook applications now, and although none of them are as successful as my friend Ben&#8217;s &#8220;Make A Baby&#8221; application, I&#8217;m very happy with how they run. Here are the tricks that I used &#8211; although you&#8217;ll find them mentioned elsewhere, and each of them is important by itself, if you&#8217;re just getting [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flickr.com/photos/jazzmasterson/3038597/"><img src="http://farm1.static.flickr.com/1/3038597_e5f95e2017_m.jpg" border="0" alt="" hspace="10" vspace="5" width="240" height="185" align="right" /></a>I&#8217;ve built several facebook applications now, and although none of them are as successful as my friend Ben&#8217;s &#8220;<a href="http://adonomics.com/about/6682280012&amp;range=max">Make A Baby</a>&#8221; application, I&#8217;m very happy with how they run. Here are the tricks that I used &#8211; although you&#8217;ll find them mentioned elsewhere, and each of them is important by itself, <strong>if you&#8217;re just getting started on your first facebook application, you need to know:</strong><span id="more-47"></span></p>
<ol>
<li>Facebook passes you the session key you want. Don&#8217;t try and use your typical, cookie or URL-based session &#8211; it <strong>won&#8217;t work.</strong> Instead (in php, for example,) start your session with:
<ol>
<li> $facebook = new Facebook($api_key, $secret);<br />
$session_key = md5($facebook-&gt;api_client-&gt;session_key);<br />
session_id($session_key);<br />
session_start();</li>
</ol>
</li>
<li>If your application is anything like mine, you&#8217;re going to have the same FBML content used all over the place &#8211; on several people&#8217;s profiles, and in the main application itself. Rather than update the contents of thousands of profiles, Facebook provides a handy <a title="FBRef Cacheing Architecture" href="http://wiki.developers.facebook.com/index.php/Fb:ref">fb:ref cacheing architecture</a>. USE IT.</li>
<li>If you&#8217;re using fb:ref (which you SHOULD be), you probably want to be using the &#8220;push&#8221; method, using <a href="http://wiki.developers.facebook.com/index.php/Fbml.setRefHandle">named handles</a>. Add the <a href="http://elliottback.com/wp/archives/2007/06/16/facebook-php-api-performance/">php curl_multi hack</a> for performance, and you&#8217;ll be off and running.</li>
<li>To take advantage of this (updating huge swaths of your application without any user interaction), you&#8217;ll probably want to run a cron job, using an <a href="http://wiki.developers.facebook.com/index.php/Infinite_session_keys">infinite session key</a>. Get yourself one.</li>
<li>The<strong> name</strong> of your application makes a huge difference when it comes to random users adding your application from the application directory. BUT, facebook doesn&#8217;t seem to mind if you change the name periodically, even after your application has been listed and you have piles of users. Go ahead and play around, and keep checking your facebook stats to see what works best.</li>
<li><a href="http://flickr.com/photos/thespeak/277904742/"><img src="http://farm1.static.flickr.com/118/277904742_39d0b61148_m.jpg" border="0" alt="" hspace="10" vspace="5" width="240" height="159" align="right" /></a>Obviously, you&#8217;ll want to run a test version. The best way is to have a second application, in developer mode, and mapped to a special port that forwards traffic <a href="http://www.cognition.ca/2007/11/using-ssh-tunnels-to-develop-facebook-applications.html">to your local development machine through an ssh tunnel</a>. Read my previous blog post on how to set this up.</li>
<li>In order to not go INSANE managing your test version, make sure you&#8217;ve abstracted out the full facebook app path, and keep it in some local config file. (Yes, I realize this should be obvious to any experienced developer). While you&#8217;re at it, you might want to check for the best possible facebook url you can get &#8211; these things are the new domain names.</li>
<li><a href="http://wiki.developers.facebook.com/index.php/Feed.publishTemplatizedAction">Facebook templatized actions</a> &#8211; <strong>you need to use these</strong>. Basically, it&#8217;s the only way to turn events within your application, into first-class citizens of the facebook news streams. They&#8217;re worthy of a full blog post on their own, as I found a whole series of gotchas when implementing them. For starters, remember to use the right fb:pronoun-s.</li>
<li><a href="http://wiki.developers.facebook.com/index.php/UsageNotes/DefaultFBML">Default FBML </a>- it&#8217;s way more important than it seems, since you can&#8217;t be sure where the user&#8217;s workflow will take them when playing with/installing your application. You&#8217;ll probably want to prototype this extensively, and then copy it from your editor into the tiny little form facebook provides.</li>
<li>It&#8217;s mentioned in all the facebook best practices, but it bears repeating &#8211; make sure you&#8217;re letting facebook users <strong>try out</strong> the functionality of your application before requiring them to install it. Not only will it lead to fewer unhappy users, but it maintains the reputation of facebook application developers as a group.</li>
<li>Post-remove &#8211; You&#8217;ll probably find, as most facebook apps do, that you have a HUGE amount of churn in your user base. If you don&#8217;t remember to remove local user data from your application database when a facebook user removes your application, it will quickly become cluttered with cruft. (A quick FQL query for whether or not each user has your application installed can be run as a one-time cleanup if necessary.)</li>
</ol>
<p>I hope you find these helpful &#8211; and if you&#8217;ve got further tips of your own, let me know!</p>
<p>UPDATE (Sept. 6th): My friend Nick wrote a book that makes this whole process easier:<br />
<iframe src="http://rcm.amazon.com/e/cm?t=cognition-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0470246669&#038;md=10FE9736YVPPT7A0FBG2&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br/></p>
<p align="right"><script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></p>
<span class="akst_link"><a href="http://www.cognition.ca/?p=47&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_47"  class="akst_share_link">Share This</a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.cognition.ca/2008/02/facebook-application-development-how-to-11-tips-you-dont-want-to-miss.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

