Giter Club home page Giter Club logo

facebookrb's Introduction

MiniFB - the simple miniature facebook library

MiniFB is a small, lightweight Ruby library for interacting with the Facebook API.

Installation

We're using gemcutter so be sure to have gemcutter as a source, then:

gem install mini_fb

General Usage

The most general case is to use MiniFB.call method:

user_hash = MiniFB.call(FB_API_KEY, FB_SECRET, "Users.getInfo", "session_key"=>@session_key, "uids"=>@uid, "fields"=>User.all_fields)

Which simply returns the parsed json response from Facebook.

Some Higher Level Objects for Common Uses

Get a MiniFB::Session:

@fb = MiniFB::Session.new(FB_API_KEY, FB_SECRET, @fb_session, @fb_uid)

Then it makes it a bit easier to use call for a particular user/session.

response = @fb.call("stream.get")

With the session, you can then get the user information for the session/uid.

user = @fb.user

Then get info from the user:

first_name = user["first_name"]

Or profile photos:

photos = user.profile_photos

Or if you want other photos, try:

photos = @fb.photos("pids"=>[12343243,920382343,9208348])

Facebook Connect

This is actually very easy, first follow these instructions: http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site

Then add the following script to the page where you put the login button so it looks like this:

<script>
    function facebook_onlogin(){
        document.location.href = "<%= url_for :action=>"fb_connect" %>";
    }
</script>
<fb:login-button onlogin="facebook_onlogin();"></fb:login-button>

Define an fb_connect method in your login/sessions controller like so:

 def fb_connect
    @fb_uid = cookies[FB_API_KEY + "_user"]
    @fb_session = cookies[FB_API_KEY + "_session_key"]
    puts "uid=#{@fb_uid}"
    puts "session=#{@fb_session}"

    # And here you would create the user if it doesn't already exist, then redirect them to wherever you want.

end

Support

Join our Discussion Group at: http://groups.google.com/group/mini_fb

facebookrb's People

Contributors

hanklords avatar bowsersenior avatar

Stargazers

Puddin' avatar

Watchers

Michael Waxman avatar

Forkers

davidhlee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.