7

I want to connect my app to Facebook in order to post on the user's wall. I want the user to click to post a message on his Wall, the pop-up of the js SDK should appear, he would login and authorize and get redirected to the home page as the pop-up disappears.

I was trying the fb_graph gem but had some hard troubles and I want to know: Is there a simpler way to do it?

Note that I don't want to make the user able to login in my app with Facebook, just post to his wall.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
rodrigoalvesvieira
  • 7,895
  • 15
  • 63
  • 84

3 Answers3

0

As Facebook does not offer any Ruby API, you will have to choose between using the JS SDK or implementing a Facebook share link.

If you only want to post in the user's wall, I recommend the second option because of ease and nature. You can customize the content of the post this way.

If you decide to go the JS way, you will have to:

  1. Create a FB app.
  2. Include FB SDK into your page.
  3. Initialize the SDK with your app settings.
  4. Ask for permissions to the user in order to post into her wall.
  5. Assign a button to a function where you check for login. If she's already logged, show a window to post into the wall (FB popup or your own form, as the iframe dialogs are only available inside Facebook pages).

There is another alternative to step 5 by using Graph API and an access token, but it's a little bit more complicated and I don't recommend it if you are new to FB development.

Community
  • 1
  • 1
Manuel Pedrera
  • 5,347
  • 2
  • 30
  • 47
0

I think, essentially, it's all or nothing when it comes to Facebook authentication. You're asking for permission to take over the user's identity and post on their Facebook wall - there will definitely be some kind of authentication and user approval. It's not a totally trivial process.

I'm sure you've looked already, but if you are OK using any of the social plugins that Facebook offers (http://developers.facebook.com/docs/plugins/), that might be an easier option to achieve what you're looking for.

If not, you'll have to gain a user's permission and post on the wall the way Facebook describes on their site. There's another gem, called Koala (https://github.com/arsduo/koala) that is pretty easy to use as well, but you can also take a look through the fb_graph documentation and see which pieces of code are applicable to your needs and duplicate that functionality.

The best source of information is on Facebook's site (http://developers.facebook.com/docs/reference/api/), where they describe the process in detail:

You can publish to the Facebook graph by issuing HTTP POST requests to the appropriate connection URLs, using an user access token or an app access token (for Open Graph Pages).

and

Most write operations require extended permissions for the active user. See the authentication guide for details on how you can request extended permissions from the user during the authentication step.

The first time I looked at this stuff I was totally overwhelmed, but play around with it and it will make a lot more sense.

I just saw @manuelpedrera 's answer, and that's a good step-by-step guide. Short answer: there's no shortcut.

Nuby
  • 2,378
  • 2
  • 21
  • 26
0

Koala is a Facebook library for Ruby, supporting the Graph API (including the batch requests and photo uploads), the REST API, realtime updates, test users, and OAuth validation.

Take a look at Koala gem: https://github.com/arsduo/koala

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
rizidoro
  • 13,073
  • 18
  • 59
  • 86