I tried out Facebook Connect with Rails recently. The result is Zack N Miri.
Figuring out all the details wasn’t super straightforward. Essentially I took the jogging php example from Facebook and combined it with the Facebooker Rails plugin. You can check out the code at Github.
Who wants to get some milk with Zack?
November 23, 2008 at 8:48 pm |
I cloned the project and tried to run it locally but I cant seem to make it past the login button. After submitting my credentials, it redirects back to fb#index with an auth_token param. It looks as though there is more functionality but I cant seem to get it to work. Any tips?
November 24, 2008 at 12:09 pm |
I guess I didn’t document the facebook settings. I have the callback url set to “http://zacknmiri.com/connect”. After you enter the fb credentials it should hit fb#connect with the auth_token param and then redirect to fb#choose_role.
You also must ensure a file exists: public/connect/xd_receiver.htm. Notice that the callback and xd_receiver have the same relative path.
December 1, 2008 at 12:06 am |
I looking at zacknmiri.com and i don’t see what fbconnect is doing for the site. i click on the fbconnect button which opens a new fb login window. i login to fb …but then what? i don’t see any connection back to the site itself… i must be missing something. any help appreciated and thanks for sharing this code.
December 1, 2008 at 1:39 am |
Facebook seems to switch between letting people use fbconnect and not. It’s still beta. The only guarantee is that developers of zacknmiri can always connect.
When fbconnect finally opens up or znm gets the green light we’ll have a party. Until then they should at least show some error messages and let people know it’s still in beta.
December 1, 2008 at 10:12 am |
OK – gotcha. So I should not infer that this is a problem in the example code .. just FB still opening this up in stages.
December 2, 2008 at 6:05 pm |
Should this be able to work fine on localhost:3000 …assuming config’d as iframe.
i am able to launch locally cloned app. and after clicking fbconnect button, first time allows me to add app via fb. subsequent refreshes do nothing but url shows: http://localhost:3000/?auth_token=320f83fc209f40ef502a792489c7d2f8
after this i am not sure what should happen. when i try to manually go to eg., http://localhost:3000/connect it redirects to choose_role but shows “error invalid parameter”.
http://pastie.org/329413
any ideas what i am not doing right? thx.
December 2, 2008 at 11:44 pm |
found a solution:
ensure_authenticated_to_facebook
needs to be at top of fb_controller.rb
December 4, 2008 at 3:37 am |
hi, I didn’t use Facebook Platform before, but I need to integrate Facebook Connect with my current Rails App, could you tell me how to do with it, thanks!!
December 9, 2008 at 6:21 pm |
It will not work on localhost. There are some ways to set up tunneling but when I am developing I map a domain name my publicly facing ip address and then have my router forward requests to port 3000 to my computer. Then in my facebook settings I make the callback URL be something like http://znm.spongecell.com:3000/zack/connect. When developing your browser should point to http://znm.spongecell.com:3000.
Remember that your xd_receiver file must have the same path as the callback url.
http://znm.spongecell.com:3000/zack/connect/xd_receiver.htm
I cleaned up ZNM a bit today. Settings are now in environment.rb instead of scattered about js files.
December 12, 2008 at 1:24 pm |
Thanks for putting the site up, Chris! I just started picking at Facebook Connect on RoR, and I’m not having any problem getting the facebook session user object on localhost (my callback URL is http://localhost:3000/facebook/connect). Also, my xd_receiver.html file isn’t in facebook/connect, it’s in another folder that I reference in my FB.Facebook.init call, and it’s working fine. I haven’t tried publishing any stories — is that when the callback URL has to be something other than localhost?
January 14, 2009 at 12:03 am |
That’s great that it will work from localhost. I didn’t realize that was possible. I thought for the first authentication facebook had to make a request to your server.
March 23, 2009 at 5:25 pm |
I’m trying to publish a one line story to my profile using the exact same method you’re using on zacknmiri.com. I get the following error:
facebook.feed.publishUserAction (0) StandardError: Feed.publishUserAction cannot be used to automatically publish one-line stories on Connect sites.: template_bundle_id = 72378344902, template_data = {“role”: “test facebook feed”}
Any ideas?
March 23, 2009 at 5:46 pm |
FB got rid of that API call. They now recommend you use the feed publisher xfbml. There are some examples in znm but github seems to be down now. Look for the Story Publisher link after you connect to znm and then “use javascript.”
March 24, 2009 at 5:42 pm |
How is ZackNMiri still working for one line stories if Facebook got rid of the API call?
Thanks for the quick response by the way.
March 25, 2009 at 10:56 am |
I’m surprised it’s still working for znm. I suppose we were grandfathered in. I did a test just now and even though znm was able to post the one line story to my profile this story did not appear in my friends’ news feeds. Lame.
Much better is to use the new story publisher. That will show up in news feeds.
April 2, 2009 at 4:31 am |
Thanks a lot, this was so helpful to me. There are fairly little examples on FB.Connect.showFeedDialog out in the net, so I was glad to see it used here.
Facebooker also has a helper for it called fb_user_action, so you can create an action with the publisher (e.g. using create_feed_role), then pass it to fb_user_action which will display Facebook’s feed dialog.
Finally, your StoryController calls ZackPublisher.register_if_needed(‘feed_role’). IMHO that should be ZackPublisher.register_if_needed(‘ZackPublisher::feed_role’). Maybe facebooker changed the way those templates are named?
April 15, 2009 at 11:25 pm |
Thanks for the tips. The FB Connect helpers look like they could be useful. I agree with you that name spacing the publishers within your app is a good idea.