<?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>Scott Rutherford &#187; facebook</title>
	<atom:link href="http://blog.thatsuseful.com/tag/facebook/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thatsuseful.com</link>
	<description>Life on and off the Rails</description>
	<lastBuildDate>Wed, 21 Jul 2010 16:35:05 +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 Friend Invites</title>
		<link>http://blog.thatsuseful.com/2007/11/27/facebook-friend-invites/</link>
		<comments>http://blog.thatsuseful.com/2007/11/27/facebook-friend-invites/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 12:37:00 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Home]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/27/facebook-friend-invites</guid>
		<description><![CDATA[I have been messing around with Facebook apps recently and I found a couple of articles to be very helpful: Tutorial On Developing A Facebook Platform Application With Ruby on Rails Continuing Facebook Applications With Ruby on Rails Fist in your Facebook I especially liked the Mime type for fbml that is from the last [...]]]></description>
			<content:encoded><![CDATA[<p>I have been messing around with Facebook apps recently and I found a couple of articles to be very helpful:</p>
<p><a href="http://www.liverail.net/articles/2007/6/29/tutorial-on-developing-a-facebook-platform-application-with-ruby-on-rails">Tutorial On Developing A Facebook Platform Application With Ruby on Rails</a></p>
<p><a href="http://www.liverail.net/articles/2007/7/16/continuing-facebook-applications-with-ruby-on-rails">Continuing Facebook Applications With Ruby on Rails</a></p>
<p><a href="http://giantrobots.thoughtbot.com/2007/6/14/fist-in-your-facebook">Fist in your Facebook</a></p>
<p>            <span id="more-538"></span></p>
<p>I especially liked the Mime type for fbml that is from the last post, simply add:</p>
<pre>
Mime::Type.register 'text/html', :fbml
ActionController::MimeResponds::Responder::DEFAULT_BLOCKS[:fbml] = %(lambda { render :action =&gt; "\#{action_name}_fbml" })
</pre>
<p>to environment.rb and off you go.</p>
<p>The first two were very helpful in getting things going but seemed to make some really simple things very complicated. One was invites. Facebook supply a very nice fbml helper for creating invite pages the <a href="http://wiki.developers.facebook.com/index.php/Fb:multi-friend-selector">fb:multi-friend-selector</a>.</p>
<p>This can be used like so:</p>
<pre>
&lt;fb:request-form action="http://apps.facebook.com/myapp" method="POST" type="MyApp" content="&lt;%= render :partial =&gt; 'invite_fbml' %&gt;"&gt;
    &lt;fb:multi-friend-selector actiontext="Select the friends you want to install MyApp" exclude_ids="&lt;%= @friends_with_app %&gt;"/&gt;
&lt;/fb:request-form&gt;
</pre>
<p>Where the invite partial looks like:</p>
<pre>
&lt;fb:name uid='&lt;%= @current_fb_user.facebook_uid %&gt;' firstnameonly='true' shownetwork='false'/&gt; wants you to install MyApp
&lt;fb:req-choice url='http://www.facebook.com/add.php?api_key=APIKEY' label='Install MyApp'/&gt;
</pre>
<p>and the controller method goes a bit like:</p>
<pre>
def index
  fql =  "SELECT uid, name FROM user WHERE uid IN" &lt;&lt;
  "(SELECT uid2 FROM friend WHERE uid1 = #{@current_fb_user.facebook_uid}) AND has_added_app = 1"
  friends = fbsession.fql_query :query =&gt; fql
  ids = []
  (friends/:user).each do|u|
    ids &lt;&lt; (u/:uid).inner_html
  end
  @friends_with_app = ids.join(',')

  respond_to do |format|
    format.html # index.rhtml
    format.fbml # index_fbml.rhtml - facebook
  end
end
</pre>
<p>Put it all together and you get something like:</p>
<p><img src="http://blog.caronsoftware.com/assets/2007/11/27/friend-selector.gif" alt="" /></p>
<p>Ta da!! You can also provide a post invite hook which will be the action provided to the facebook form element.</p>
<p>Now go and install <a href="http://apps.facebook.com/nothingapp">Nothing</a> to see it in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thatsuseful.com/2007/11/27/facebook-friend-invites/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
