# Rest-graph 1.0.0 - super simple facebook open graph api client

**URL:** <https://www.ruby-forum.com/t/rest-graph-1-0-0-super-simple-facebook-open-graph-api-client/188135>\
**Category:** Ruby\
**Created:** [May 6, 2010, 11:43am UTC](https://www.ruby-forum.com/t/rest-graph-1-0-0-super-simple-facebook-open-graph-api-client/188135 "2010-05-06T11:43:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lin\_Jen-Shin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/7993a0/32.png) [@Lin\_Jen-Shin](https://www.ruby-forum.com/u/Lin_Jen-Shin)\
**Post date:** [May 6, 2010, 11:43am UTC](https://www.ruby-forum.com/t/rest-graph-1-0-0-super-simple-facebook-open-graph-api-client/188135/1 "2010-05-06T11:43:59Z")

</div>

= rest-graph 1.0.0  
by Lin Jen-Shin (aka godfat-çœŸå¸¸[[http://godfat.org](http://godfat.org)])  
godfat (XD) [godfat.org](http://godfat.org)

== LINKS:

- {github}[[GitHub - godfat/rest-graph: A lightweight Facebook Graph API client](http://github.com/godfat/rest-graph)]
- {rubygems}[[rest-graph | RubyGems.org | your community gem host](http://rubygems.org/gems/rest-graph)]
- {rdoc}[[http://rdoc.info/projects/godfat/rest-graph](http://rdoc.info/projects/godfat/rest-graph)]

== DESCRIPTION:

super simple facebook open graph api client

== FEATURES:

- simple graph api call
- simple fql call
- utility to extract access\_token and check sig in cookies

== SYNOPSIS:

require ‘rest-graph’

# every option is optional!!

rg = RestGraph.new(:access\_token =\> ‘…’,  
:graph\_server =\> ‘[https://graph.facebook.com/](https://graph.facebook.com/)’,  
:fql\_server =\> ‘[https://api.facebook.com/](https://api.facebook.com/)’,  
:accept =\> ‘text/javascript’,  
:lang =\> ‘en-us’, # this affect search  
:auto\_decode =\> true, # decode by json  
:app\_id =\> ‘123’,  
:secret =\> ‘1829’)  
rg.get(‘me’)  
rg.post(‘feed/me’, :message =\> ‘bread!’)

# for rack

lambda{ |env|  
rg = RestGraph.new(:app\_id =\> ‘123’, :secret =\> ‘1829’)  
rg.parse\_rack\_env!(env) # auto save access\_token if sig checked  
rg.access\_token # =\> …  
rg.data[‘uid’] # =\> facebook uid  
}

# for fully blown cookies hash

rg = RestGraph.new(:app\_id =\> ‘123’, :secret =\> ‘1829’)  
rg.parse\_cookies!(cookies) # auto save access\_token if sig checked  
rg.access\_token # =\> …  
rg.data[‘uid’] # =\> facebook uid

# for fbs in cookies

app\_id = ‘456’  
rg = RestGraph.new(:app\_id =\> ‘123’, :secret =\> ‘1829’)  
fbs = cookies[“fbs\_#{rg.app\_id}”]  
rg.parse\_fbs!(fbs) # auto save access\_token if sig checked  
rg.access\_token # =\> …  
rg.data[‘uid’] # =\> facebook uid

# fql query

rg.fql(‘SELECT name FROM page WHERE page\_id=“123”’)

== REQUIREMENTS:

- tested with MRI 1.8.7 and 1.9.1
- gem install rest-client
- gem install json (optional)
- gem install json\_pure (optional)
- gem install rack (optional, to parse access\_token in HTTP\_COOKIE)

== INSTALL:

> gem install rest-graph

# or if you want rails plugin and bleeding edge

> script/plugin install git://github.com/godfat/rest-graph.git

== LICENSE:

Apache License 2.0

Copyright (c) 2010, Lin Jen-Shin (aka godfat çœŸå¸¸)

Licensed under the Apache License, Version 2.0 (the “License”);  
you may not use this file except in compliance with the License.  
You may obtain a copy of the License at

```
 http://www.apache.org/licenses/LICENSE-2.0

```

Unless required by applicable law or agreed to in writing, software  
distributed under the License is distributed on an “AS IS” BASIS,  
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
implied.  
See the License for the specific language governing permissions and  
limitations under the License.
