Skip to content

Instantly share code, notes, and snippets.

@hayesdavis
Created November 29, 2010 03:08
Show Gist options
  • Save hayesdavis/719542 to your computer and use it in GitHub Desktop.
Save hayesdavis/719542 to your computer and use it in GitHub Desktop.
require 'grafl'
# Get the root node (assumes you have an access token)
root = Grafl.root(:access_token=>'foo')
# Get the current user
user = root/:me
puts user.name
# Get the user's news feed
news = user/:home
# Post a wall item (with appropriate permissions)
user.post!("feed",:message=>"howdy")
# or
feed = user/:feed
feed.post(:message=>"howdy")
# Do a search
results = root.get("search",:q=>"stuff",:type=>:posts)
posts = results.data
# Authentication
auth = Grafl.auth(:client_id=>'foo',:client_secret=>'secret',:redirect_url=>"http://example.com/")
url = auth.authorize_url(:scope=>:read_stream)
# Redirect the user to the url, get a redirect back, get code param from userl
result = auth.authorize!(code)
# Use auth
root = Grafl.root(:access_token=>result.access_token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment