I am exploring facebook integration with my rails app and wondering what is the best practice for rails applications.
1 - Is js sdk the better route or the facebooker gem? I would like to allow users to login via facebook, post content/links to their walls, see friend activity in the application, invite fb friends, from the rails app etc.
2 - Can either of these methods be tested locally or do I need a hosted internet app?
3 - I already do fb authentication for login using janrain/rpx-now via authlogic-rpx plugin. Will this have any conflict with the facebooker gem or the fb js sdk. And..in order to use the fb pluging/js sdk/facebooker etc, is it required to do the authentication via those methods or can I authenticate via rpx/janrain but access feeds/friend activity etc from the facebooker gem/js sdk etc?
Thanks
1) I often use both. I find most of the work to be easier using the server side SDK, but we do occasionally use the js one as well. I would check out Facebooker2, it's much more simple than the original Facebooker
2) Both can be used locally, but you do need internet connectivity to talk to Facebook.
3) If you get a valid access token, you can use Facebooker with the RPX stuff. You would need to change the way you do the client setup.
Related
I have created a Rails (3.2) application that uses the OmniAuth gem to provide OAuth authentication. Users can log into the site using their Twitter, Facebook or Google credentials, pretty bog-standard functionality.
I now want to make the data available via an API so it can be consumed outside of my web application, however, users would still have to login to be able to access their data. How do I do this in my Rails APP? And what would the user have to do to be able to call this?
UPDATE
Some people are suggesting "alternative" authentication methods, but I am wondering if I cannot use the same OAuth credentials I already have for them. I don't want them to have to provide another username/pwd, I want them to be able to use their Twitter, Facebook or Google Identities as they do when they use the WebUI.
authenticate_with_http_basic (or digest if you like) might work for you, called from a before filter in the controller.
You can test with curl, using the --user parameter.
Here's a good thread on the topic:
In Ruby on Rails, what does authenticate_with_http_basic do?
Devise has the feature token authentication which is what you are looking for.
Also visit http://zyphmartin.com/blog/simple-auth-token-example-with-devise
I want my web application, which is built with Ruby on Rails, to communicate with the Facebook Social Graph API, but I am aware of that I need some kind of authorization to achieve that.
So, do I need to build OAuth authentication for my application to make use of auto-publishing messages on the user's Facebook wall?
If not, how could I integrate the social features into my web application?
The web application already has an existing user base; could I also allow my application to get Facebook access? If yes, how?
I would appreciate examples of sites who do this kind of integration really well, also with other services like Twitter, LinkedIn, etc..
All is explained on the facebook developers site:
http://developers.facebook.com/
This explains the auth you need to access graph
http://developers.facebook.com/docs/guides/web/#login
You can then combine graph info with your existing user database by saving their facebook ID number hence then you can pull up profile pics etc
Try using the following gems:
Devise: User authentication (If you already have the framework for user authentication, this will not be needed.
Omniauth: Facebook (or any other OAauth e.g. Twitter) authentication
Koala: Facebook open graph api
If you need only Facebook integration, Koala should be sufficient.
For making them work together check this:
Making OmniAuth, Devise and Koala work together
Using the current rails 2
I want users to be able to create an account from:
traditional signup
twitter
facebook
and then allow them to link facebook and/or twitter and/or traditional signup later.
I read this http://www.themomorohoax.com/2009/02/21/rails-2-3-authentication-comparison
and decided to check out:
Authlogic
Restful Authentication
Devise/Warden
It seems for at least some of the plugins you can use with them that making OAuth work with them will make them incompatible with any other login system.
Will I need to roll my own from the ground up, or can I glue together some existing pieces?
You can glue together existing pieces.
I wouldn't advise for Restful Authentication. It's getting old and isn't maintained anymore.
If you plan on using Authlogic, you can take a look at those two gems :
authlogic oauth for any oauth service (including twitter)
authlogic facebook connect
If you plan on using Devise, you can take a look at those two gems :
warden oauth for any oauth service (including twitter)
device facebook connectable
Can I use Facebooker without having to create a whole Facebook App in their Developer section?
I don't need to create a Facebook App with Facebooker, I just want to be able to create events and posts on Facebook with my own custom admin panel on my site. Facebooker seems to have everything built already, so I wouldn't want to use just a raw Rest-Client library.
Can I use Facebooker to read/write to Facebook without creating an App? I'd love to know. If not, can I read/write to Facebook without creating an App another way without resorting to either raw REST requests or page scraping/mechanize?
Thanks for clearing this up.
You have to have created an App in order to get an API key and Secret Key. You must have these keys in order to use any of the FB platform API (including Facebook connect).
I am using RPXnow.com authentication solution for a rails app and am now at the point of wanting to develop Facebook integration features using Facebook Connect and the client api. What I am unclear on from RPXnow docs is the level of integration their solution provides. When a user connects via rpx using their FB creds, are they now using Facebook Connect? Can I make calls to the client api from my app? Do I need to use the RPX api to access the FB client APIs?
Anyone with experience using both who can shed light here, much appreciated.
dnewman,
Great question. Facebook Connect is simply a javascript layer built on top of the Facebook Platform APIs. RPX uses the platform APIs to authenticate the user, and after they have signed in, you may safely use the native Facebook Connect javascript to implement FB specific features on your site like posting activity back to the News Feed. You just need to set your connect URL on the facebook developer site and drop in the Facebook Connect javascript and then start implementing. After authenticating via RPX, the user will already have approved and "connected" to your website, and you'll have access to the breadth of Connect directly.
Also, if you have an RPX Plus/Pro account you can make simple RPX API calls to set a user's status and post activity on Facebook (and Twitter/MySpace).
Brian Ellin
RPX Product Manager
Once you've hooked up RPXNow (JanRain) single sign-on, you can follow the Facebook documentation. The Server-side Personalization example is in PHP but the idea is the same in any language.
// Fetch the user's friends
$friends = json_decode(file_get_contents(
'https://graph.facebook.com/me/friends?access_token=' .
$cookie['oauth_access_token']), true);
$friend_ids = array_keys($friends);
The key point to note is that the $cookie['oauth_access_token'] referenced in this example needs to be the string returned by the RPXNow sign-on API response in the JSON field
['accessCredentials']['accessToken']
Hint: from your RPXNow dashboard, check out the Test Sign-In Widget page under Resources to see where that token is in the response.
Initially I thought this would be hampered by having your Base Domain set to rpxnow.com in your Facebook Application settings, but this is not the case. It works fine.