Class: FacebookClient::Graph
- Inherits:
-
Object
- Object
- FacebookClient::Graph
- Defined in:
- lib/graph.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
- #connection ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(fb, access_token, expires = nil) ⇒ Graph
constructor
A new instance of Graph.
-
#parse_response(response) ⇒ Object
processing access token.”, “type”=>“OAuthException”}.
Constructor Details
#initialize(fb, access_token, expires = nil) ⇒ Graph
Returns a new instance of Graph.
11 12 13 14 15 16 17 18 |
# File 'lib/graph.rb', line 11 def initialize(fb, access_token, expires=nil) @fb=fb @access_token=access_token if expires.nil? expires=0 end expires=expires.to_i end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
9 10 11 |
# File 'lib/graph.rb', line 9 def access_token @access_token end |
Instance Method Details
#connection ⇒ Object
39 40 41 42 43 44 |
# File 'lib/graph.rb', line 39 def connection @connection ||= Faraday::Connection.new(:url => Base::GRAPH_URL) do |builder| builder.adapter :net_http builder.response :yajl end end |
#get(path, params = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/graph.rb', line 20 def get(path, params={}) params = params.stringify_keys params['access_token'] = @access_token response = connection.run_request(:get, path, nil, {}) do |request| request.params.update(params) end response = parse_response(response) return response end |
#parse_response(response) ⇒ Object
processing access token.”, “type”=>“OAuthException”}
31 32 33 34 35 36 37 |
# File 'lib/graph.rb', line 31 def parse_response(response) body = response.body if body.is_a?(Hash) and body.has_key?('error') raise ResponseError, "#{body['error']['message']}" end return body end |