Skip to content

Instantly share code, notes, and snippets.

@juanjoseijas
Created November 19, 2014 19:29
Show Gist options
  • Select an option

  • Save juanjoseijas/707b1cfb0b8dd8d45e5d to your computer and use it in GitHub Desktop.

Select an option

Save juanjoseijas/707b1cfb0b8dd8d45e5d to your computer and use it in GitHub Desktop.

Revisions

  1. juanjoseijas created this gist Nov 19, 2014.
    29 changes: 29 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    require 'rubygems'
    require 'httparty'

    ## define class
    class Facebook
    ## load and inherit HTTParty class
    include HTTParty
    ## set the default base URI
    base_uri 'https://graph.facebook.com'
    ## set the format to JSON, so that HTTParty will automatically decode it
    format :json

    ## constructor
    def initialize(access_token)
    @access_token = access_token
    end

    def get_info
    self.class.get('/me',:query => { :access_token => @access_token })
    end
    end

    ## create an instance of the Facebook class
    fb = Facebook.new(<your-access-token>);

    ## call the method
    r = fb.get_info()

    print r.body