Class: FacebookGraph::Client
- Inherits:
-
Object
- Object
- FacebookGraph::Client
- Includes:
- Helper
- Defined in:
- lib/facebook-graph/base/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
- #current_user(options = {}) ⇒ Object
- #get_node(element_id, options = {}) ⇒ Object
-
#initialize(access_token = nil) ⇒ Client
constructor
A new instance of Client.
- #search(query, options = {}) ⇒ Object
Methods included from HTTPHelper
Constructor Details
#initialize(access_token = nil) ⇒ Client
Returns a new instance of Client.
4 5 6 |
# File 'lib/facebook-graph/base/client.rb', line 4 def initialize(access_token=nil) @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
30 31 32 |
# File 'lib/facebook-graph/base/client.rb', line 30 def access_token @access_token end |
Instance Method Details
#current_user(options = {}) ⇒ Object
18 19 20 |
# File 'lib/facebook-graph/base/client.rb', line 18 def current_user(={}) get_node('me', ) end |
#get_node(element_id, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/facebook-graph/base/client.rb', line 8 def get_node(element_id, ={}) config = FacebookGraph.configuration uri = "#{config[:base_uri]}/#{element_id}" uri += "#{querystring_separator(uri)}access_token=#{CGI.escape(@access_token)}" if @access_token uri += "#{querystring_separator(uri) + hash_to_querystring()}" unless .nil? || .empty? node = FacebookGraph::GraphNode.new(parse_json(uri)) node.access_token = access_token node end |
#search(query, options = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/facebook-graph/base/client.rb', line 22 def search(query, ={}) config = FacebookGraph.configuration uri = "#{config[:base_uri] + config[:search_uri]}?q=#{CGI.escape(query)}" uri += "&access_token=#{CGI.escape(@access_token)}" if @access_token uri += "&#{hash_to_querystring()}" unless .nil? || .empty? FacebookGraph::GraphNode.from_array(parse_json(uri)) end |