Created
November 29, 2010 03:08
-
-
Save hayesdavis/719542 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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