[ANN] rest-graph 1.0.0 - super simple facebook open graph api client

L

Lin Jen-Shin

=3D rest-graph 1.0.0
by Lin Jen-Shin (aka godfat-=E7=9C=9F=E5=B8=B8[http://godfat.org])
godfat (XD) godfat.org

=3D=3D LINKS:

* {github}[http://github.com/godfat/rest-graph]
* {rubygems}[http://rubygems.org/gems/rest-graph]
* {rdoc}[http://rdoc.info/projects/godfat/rest-graph]

=3D=3D DESCRIPTION:

super simple facebook open graph api client

=3D=3D FEATURES:

* simple graph api call
* simple fql call
* utility to extract access_token and check sig in cookies

=3D=3D SYNOPSIS:

require 'rest-graph'

# every option is optional!!
rg =3D RestGraph.new:)access_token =3D> '...',
:graph_server =3D> 'https://graph.facebook.com/',
:fql_server =3D> 'https://api.facebook.com/',
:accept =3D> 'text/javascript',
:lang =3D> 'en-us', # this affect search
:auto_decode =3D> true, # decode by json
:app_id =3D> '123',
:secret =3D> '1829')
rg.get('me')
rg.post('feed/me', :message =3D> 'bread!')

# for rack
lambda{ |env|
rg =3D RestGraph.new:)app_id =3D> '123', :secret =3D> '1829')
rg.parse_rack_env!(env) # auto save access_token if sig checked
rg.access_token # =3D> ...
rg.data['uid'] # =3D> facebook uid
}

# for fully blown cookies hash
rg =3D RestGraph.new:)app_id =3D> '123', :secret =3D> '1829')
rg.parse_cookies!(cookies) # auto save access_token if sig checked
rg.access_token # =3D> ...
rg.data['uid'] # =3D> facebook uid

# for fbs in cookies
app_id =3D '456'
rg =3D RestGraph.new:)app_id =3D> '123', :secret =3D> '1829')
fbs =3D cookies["fbs_#{rg.app_id}"]
rg.parse_fbs!(fbs) # auto save access_token if sig checked
rg.access_token # =3D> ...
rg.data['uid'] # =3D> facebook uid

# fql query
rg.fql('SELECT name FROM page WHERE page_id=3D"123"')

=3D=3D 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)

=3D=3D INSTALL:
gem install rest-graph
# or if you want rails plugin and bleeding edge
script/plugin install git://github.com/godfat/rest-graph.git

=3D=3D LICENSE:

Apache License 2.0

Copyright (c) 2010, Lin Jen-Shin (aka godfat =E7=9C=9F=E5=B8=B8)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top