Facebook gem for Ruby on Rails - ruby-on-rails

I am going to make a very simple web application. I only need the friend list of the current user and then send a message to a selected user with an image/text. I have looked after gems that wraps the detail of extracting data from Facebook and I found some gems, but they all use the old REST API. First of all: is it bad to use the REST API? If not, is "Facebooker" a good gem? If it is bad I found this Which Ruby gems support the Facebook API? but I don't see much of documentation for the Facebooker2. Are there other options?

i'm using koala - works with OAuth authentication and Facebook Graph API. Didn't have any serious problems with it, and it's pretty well documented (with examples) on github

The Ruby Toolbox is a great resource for this kind of question.
In your case, try searching for 'facebook' -- as in https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=facebook -- and you'll find that https://github.com/nov/fb_graph is a popular and well-maintained FB gem (at least riight now).

Since Facebook introduced the Open Graph API I've found it's pretty easy to just roll my own wrapper for the REST calls I need using an http client like HTTParty or RestClient. YMMV.

Related

how to read data from api without any gem rails 3

I want to read data from an API ean without using any gem. What I want is when the user searches for a particular hotel then my query should return me a data from ean.
How can I go about this thing? and how/where do I add the api key and secret ?
You can perform HTTP requests in Ruby using the Net::HTTP standard library.
Most people prefer to use third party Gems because they offer additional features or cleaner API, compared to Net::HTTP.
However, most of them is based on Net::HTTP itself.
Its a soap API you can use savon to build your own class to access that api. YOu will find a screencast for savon here: http://railscasts.com/episodes/290-soap-with-savon I had a look at the documentation its pretty well documented.

Rails 3. Building an oauth2 provider

I am developing an API in Ruby on Rails 3 and I would like to secure it with Oauth2.
In other words, I need to create an Oauth provider. Is there a working gem for Rails 3 out there or perhaps a tutorial on the issue?
UPDATE
I know Rails are REST based so I find it very strange that there are no tutorials on how to create a public API and secure it. Does anyone know of any good tutorials. Preferable with oAuth.
Thankful for all help!!
Check out this gem https://github.com/applicake/doorkeeper
It is for Rails 3, the development it's early stages though.
There's also an example app that you take a look and see how the API is done.
http://doorkeeper-provider.herokuapp.com/
I've opensourced an OAuth2 server implementation yesterday.
It's well documented and there is a dashboard to control accesses. Right now I'm searching for somebody who wants to build an engine starting from it, or something cool on top of rack. That's why it is open-source.
https://github.com/intridea/oauth2 is the canonical gem right now for OAuth2 dev. If you are looking for a more complete solution, instead of rolling your own provider code, check out:
https://github.com/songkick/oauth2-provider
https://github.com/freerange/oauth2-provider
But I suggest messing around with the oauth2 gem if you aren't very familiar with the flow so that you can learn it better.
If you are using (or planning to use) devise for authentication, you can use https://github.com/socialcast/devise_oauth2_providable as plugin.
I'm developing a rugygem for OAuth2 provider, Rack::OAuth2.
https://github.com/nov/rack-oauth2
It requires to develop models (token, code, client etc) by yourself, but you can get a whole Rails3 sample OAuth2 server here.
https://github.com/nov/rack-oauth2-sample
I'm looking to implement an OAuth2 provider, too! I'm currently experimenting with this https://github.com/assaf/rack-oauth2-server, which seems to be a full-featured OAuth2 server, though it still supports only MongoDB, although implementing support for other DBMS seems simple enough. I am also looking at some of the other options posted here, lots of promising stuff!
"Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider functionality to your application."
https://github.com/applicake/doorkeeper

What's the best gem/plugin to develop a Facebook Canvas/iFrame App (Rails 2.3.8, Ruby 1.8.7)?

we're developing a Facebook Canvas App in Rails 2.3.8, we tried a couple of gems out there and for now we're using mini_fb but it's not really well documented and we're having some issue with the authentication/authorization process, and more importantly we couldn't find a tutorial on how integrate cucumber.
I know there're plenty of options out there: facebooker (too old?), oauth2 gem, omniauth, mogli and so on.
What we ideally need is:
Support for Canvas/iFrame app (not just Facebook connect)
Support for the new OAuth 2.0 for Canvas (beta) facebook docs & for the old REST API as well
Documentation (very hard to find, also cause Facebook API are in first place not so extensively documentend, especially for Ruby)
Support/Documentation/Tutorials for Cucumber integration
Cover basic API features like Wall posting, Friends handling ...
What's the best option in your opinion/past experience?
Thank you guys,
Leo
Take a look at Koala...
https://github.com/arsduo/koala/
Very well documented and maintained.
Works with Ruby 1.8/1.9 & Rails 2/3

Need Recommendations for Twitter and Facebook Gems

I'm building an app in Rails 3. I currently have a user model which is authenticated via devise (email + password auth). I want to be able to show connect to facebook, connect to twitter buttons to the users once they are logged in.
After obtaining the keys from Facebook and Twitter, I'd want to store it in the database for future requests.
Which Ruby Gems should I be using for this use case?
Thanks!
Instead of Facebooker, we just implemented a facebook-connect style login and application using mini_fb
Mini_fb uses the new graph API, which is cool, and was easy to implement. We used Rails3 and authlogic, but difference to devise should be negligible.
For twitter, this twitter gem is nice, but this devise-twitter gem looks nice for login.
Okay, still no answers. Please check out the Ruby Toolbox, I'm sure the answer is there. It will tell you what the most common gems are for your problem if you can figure out the categorization system. Also, facebooker is a nice gem but it's a little old.
Facebooker is deprecated in favour of mogli, which uses the Graph API. And for Twitter, I'd recommend John Nunemaker's twitter. Since you are already using Devise, you can use the devise-twitter as mentioned by Jesse Wolgamott.

How do I connect to Gmail's IMAP server using oauth in Rails3?

I found the gmail_xoauth gem, which does most of what I need, but I also need to generate the oauth tokens (consumer_key and consumer_secret) from inside Rails3.
I am trying to integrate Gmail's oauth integration into my site and hence cannot use the python script that the above gem refers to. I would like my site to take the user to the authentication page and extract the consumer_key/secret tokens.
I am new to OAuth, so maybe there's something obvious that I am missing.
UPDATE: I solved the above, and have written a blog post with the details (since its too big to fit here).
http://blog.asif.in/blog/2012/03/03/google-oauth-and-rails/
You may want to check out OmniAuth. It's a gem that encapsulates/abstracts a lot of the underlying protocol work that must be done for OAuth, as well as other authentication/authorization protocols like OpenID and LDAP. I'm not well versed on Google's API for sending/receiving email, but authenticating is the first step.
The OmniAuth wiki has a very good tutorial on using it with OpenID and Google Apps, although this may not be quite what you're looking for when it comes to IMAP. You may need to write your own provider for OmniAuth (a good tutorial describing this is available). Google also provides a reference site for authenticating/authorizing via IMAP and OAuth. The most relevant part of that to you would most likely be the page detailing the protocol.
Hope that helps!
I'm not going to write the full code for you, but do you know PHP? You could have a look at the way this example works:
http://googlecodesamples.com/docs/php/Docs.php
...then make something similar in Ruby.
This is a Google Code Sample from the following site:
http://googlecodesamples.com/

Resources