views:

1291

answers:

4

I'm attempting to create a facebook app and went through the book http://pragprog.com/titles/mmfacer/developing-facebook-platform-applications-with-rails. Everything works fine on my development machine when I have my canvas render method set as fbml. But, for various reasons I want to build an app with an iframe. When I set my app to use an iframe I am unable to connect to my development machine. I went through a lot of different articles about creating an iframe app, but none seem to work. That includes

http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel
http://wiki.developers.facebook.com/index.php/XFBML
and any other site found googling any combination of facebook, iframe, rails and others.

I have the xd_receiver.htm file in my public directory and my layout looks like

<!doctype html public “-//w3c//dtd xhtml 1.0 strict//en” “http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml” xmlns:fb=”http://www.facebook.com/2008/fbml”&gt;
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title><%= controller.controller_name %>: <%= controller.action_name %></title>
  <%= stylesheet_link_tag "jquery-ui-1.7.1.custom.css", "styles" %>
  <%= javascript_include_tag "jquery-1.3.2.min.js", "application" %>
</head>
<body>

<%= yield  %>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">  
    FB_RequireFeatures(["XFBML"], function(){ 
    FB.Facebook.init("my api key", "xd_receiver.htm"); });
</script>
</body>
</html>

My question is, what am I missing that is preventing facebook from connecting to my rails development machine when I set the canvas render method to iframe? Since my development log does not show any attempts of a connection, I'm guessing that it has something to do with the cross domain stuff, but I can't find a good answer about it anywhere.

+3  A: 

If you place that file under /public, its important to note that the ERB contained within the template will not get parsed as you expected. I'm not too familiar with the plugin you are trying to use but have used the Facebooker gem (http://facebooker.rubyforge.org/) which provides a tidy way to interact with the Facebook REST API.

joshnesbitt
(i would post a comment instead of an answer but my score doesn't let me).
joshnesbitt
A: 

I strongly suggest using Facebooker from the beginning. It'll save you a lot of time.

Zepplock
A: 

/xd_receiver

there are facebooker methods for this sort of thing check this out

http://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/

A: 

facebooker assumes you are using fbml .what if you are to use an iframe?

Mugisha