<?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; fbml</title>
	<atom:link href="http://www.cognition.ca/tag/fbml/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cognition.ca</link>
	<description>Balls-in-the-air Entrepreneurship and Juggling.</description>
	<lastBuildDate>Thu, 22 Jul 2010 06:34:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</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>
		<item>
		<title>Using SSH Tunnels to develop Facebook Applications</title>
		<link>http://www.cognition.ca/2007/11/using-ssh-tunnels-to-develop-facebook-applications.html</link>
		<comments>http://www.cognition.ca/2007/11/using-ssh-tunnels-to-develop-facebook-applications.html#comments</comments>
		<pubDate>Wed, 21 Nov 2007 01:55:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[entrepreneurs]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook applications]]></category>
		<category><![CDATA[fbml]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh tunnel]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.cognition.ca/?p=17</guid>
		<description><![CDATA[One of the most frustrating things I found early on when working on facebook applications, was that there was no simple way to create a local development environment. Because so many of the features of the platform existed only when the code was executed THROUGH the facebook proxy (fbml parsing, fb:ref cache content, etc), I [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most frustrating things I found early on when working on facebook applications, was that there was no simple way to create a local development environment. Because so many of the features of the platform existed only when the code was executed THROUGH the facebook proxy (fbml parsing, fb:ref cache content, etc), I found myself in an almost endless cycle of &#8220;svn commit&#8221;, &#8220;svn up&#8221; on the test server. Although I could have reduced this to a single step using a capistrano deployment task, or (heavens forbid) simply edited the code in place on the server using VI, I wasn&#8217;t happy with either of these options.</p>
<p>By happy coincidence, I spent the day hacking away on FB apps with my friend Ben Savage, who showed me how *he* does it &#8211; he simply port forwards port 4100 on his local router into his laptop, and then sets the facebook application to use his current outside IP:4100 as the app url.</p>
<p>I didn&#8217;t like this for a few reasons &#8211; first, it requires admin access to the router, a no-go from Starbucks. Second, I don&#8217;t like having to change my facebook application settings every time I change offices. So I decided to try using an ssh tunnel.</p>
<p>After mucking about a bit, I got it working! Here&#8217;s what I had to do (and yes, it&#8217;s pretty ugly and you probably want to do this on a non-critical junk proxy box you&#8217;ve got somewhere):</p>
<p><span style="font-style: italic">Changes to /etc/ssh/sshd_config</span></p>
<p>1. You have to make the ssh connection as root in order to bind to a privileged port (it&#8217;s probably trivial to use a non-privileged port for this, but I couldn&#8217;t be bothered). So you need to enabled root logins, by adding/changing<br />
PermitRootLogin yes<br />
2. In order to bind to a network address other than localhost on the remote server, you need<br />
GatewayPorts yes</p>
<p>Then you simply run this from console on your local machine:</p>
<p>ssh root@mytunnelbox.com -p22 -N -R *:8090/localhost/80</p>
<p>This will forward port 8090 on your remote server to port 80 on your local workstation, via ssh tunnel. I don&#8217;t usually bother to fork into the background, because it&#8217;s nice to be able to ctrl-c to finish up.</p>
<p>Now get into your facebook developer application (you probably want to create a test application for this), and change the Callback URL to mytunnelbox.com:8090/. (You&#8217;ll only have to do this the first time).</p>
<p><a href="http://bp1.blogger.com/_sHhNhXF24IE/R0OmAZKjrUI/AAAAAAAAAAc/iRFMFoZWyiU/s1600-h/Picture+5.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img src="http://bp1.blogger.com/_sHhNhXF24IE/R0OmAZKjrUI/AAAAAAAAAAc/iRFMFoZWyiU/s400/Picture+5.png" style="cursor: pointer" id="BLOGGER_PHOTO_ID_5135130525817875778" border="0" /></a></p>
<p>Voila! Local development facebook application work &#8211; from Starbucks or anywhere else!</p>
<span class="akst_link"><a href="http://www.cognition.ca/?p=17&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_17"  class="akst_share_link">Share This</a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.cognition.ca/2007/11/using-ssh-tunnels-to-develop-facebook-applications.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
