Star in a Porno with Facebook Connect and Rails

I tried out Facebook Connect with Rails recently. The result is Zack N Miri.

znmFiguring 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?

Advertisements

22 Responses to Star in a Porno with Facebook Connect and Rails

  1. Stephen says:

    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?

  2. Chris Hobbs says:

    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.

  3. DanNewman says:

    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.

  4. Chris says:

    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.

  5. DanNewman says:

    OK – gotcha. So I should not infer that this is a problem in the example code .. just FB still opening this up in stages.

  6. DanNewman says:

    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.

  7. DanNewman says:

    found a solution:

    ensure_authenticated_to_facebook

    needs to be at top of fb_controller.rb

  8. Jeff says:

    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!!

  9. Chris Hobbs says:

    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.

  10. Mike says:

    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?

  11. Chris Hobbs says:

    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.

  12. Chris Chan says:

    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?

  13. Chris Hobbs says:

    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.”

  14. Chris Chan says:

    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.

  15. Chris Hobbs says:

    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.

  16. Jonas Wagner says:

    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?

  17. Chris Hobbs says:

    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.

  18. Like IT says:

    Like IT…

    […]Star in a Porno with Facebook Connect and Rails « Spongecell Tech Blog[…]…

  19. rap blog says:

    I am curious to find out what blog system you happen to
    be utilizing? I’m experiencing some minor security issues with my latest site and I’d like
    to find something more safe. Do you have any solutions?

  20. I know this if off topic but I’m looking into starting my own blog and was curious what all is needed to get set up? I’m
    assuming having a blog like yours would cost a pretty penny?
    I’m not very internet smart so I’m not 100% sure. Any
    recommendations or advice would be greatly appreciated.
    Kudos

  21. erotyka says:

    This is a really good tip especially to those new to the blogosphere.
    Brief but very accurate info… Thank you for sharing this
    one. A must read post!

  22. I enjoy what you guys are usually up too. This type of clever work and reporting!
    Keep up the terrific works guys I’ve incorporated you guys to my own blogroll.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: