Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added more examples to readme

  • Loading branch information...
commit 9c4fc3a3735e8faf6d649ad8eabefbff6a93fb7c 1 parent 21a65e5
Conor Hunt authored
Showing with 14 additions and 15 deletions.
  1. +11 −12 README.md
  2. +2 −2 lib/rfgraph/request.rb
  3. +1 −1  rfgraph.gemspec
View
23 README.md
@@ -16,6 +16,16 @@ gem install rfgraph
Example
-------
+Without auth token
+
+ require 'rfgraph'
+ req = RFGraph::Request.new
+ req.get_object("19292868552")
+ req.get_object("99394368305/photos")
+ req.get_object("331218348435", "metadata" => "1")
+
+With auth token
+
require 'rfgraph'
fauth = RFGraph::Auth.new(APP_ID, APP_SECRET)
@@ -28,18 +38,7 @@ Example
# Make some requests, auth token is only required if you are doing requests that need it.
request = RFGraph::Request.new(auth_token)
request.get_object("me")
-
- # Returns something like
- #{
- # "id" => "57373737593",
- # "name" => "Some User",
- # "first_name" => "Some",
- # "last_name" => "User",
- # "link" => "http://www.facebook.com/someuser",
- # "timezone" => -4,
- # "verified" => true,
- # "updated_time" => "2010-03-30T01:27:19+0000"
- # }
+ request.get_object("me/friends")
request.put_wall_post("Awesome message!")
View
4 lib/rfgraph/request.rb
@@ -57,14 +57,14 @@ def request(path, url_args = {}, post_args = nil)
end
end
- encoded_url_args = url_args.collect {|k,v| "#{CGI.escape k}=#{CGI.escape v}" }.join("&")
+ encoded_url_args = url_args.collect {|k,v| "#{CGI.escape k.to_s}=#{CGI.escape v.to_s}" }.join("&")
url = URI.parse("#{BASE_URL}/#{path}?#{encoded_url_args}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = if post_args
- encoded_post_args = post_args.collect {|k,v| "#{CGI.escape k}=#{CGI.escape v}" }.join("&")
+ encoded_post_args = post_args.collect {|k,v| "#{CGI.escape k.to_s}=#{CGI.escape v.to_s}" }.join("&")
http.post("#{url.path}?#{url.query}", encoded_post_args)
else
http.get("#{url.path}?#{url.query}")
View
2  rfgraph.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'rfgraph'
- s.version = '0.2'
+ s.version = '0.3'
s.date = '2010-04-21'
s.authors = ['Conor Hunt']
s.email = 'conor.hunt@gmail.com'
Please sign in to comment.
Something went wrong with that request. Please try again.