Class: FacebookGraph

Inherits:
Object
  • Object
show all
Includes:
FacebookHttp
Defined in:
lib/fbauth/graph.rb

Constant Summary collapse

FB_GRAPH_URL =
"https://graph.facebook.com"

Instance Method Summary collapse

Methods included from FacebookHttp

#build_get_url, #build_query_string, #caching_enabled?, #get, #has_access_token?, #logger, #merged_options, #post

Constructor Details

#initialize(access_token = nil, options = {}) ⇒ FacebookGraph

Returns a new instance of FacebookGraph.



9
10
11
# File 'lib/fbauth/graph.rb', line 9

def initialize(access_token = nil, options = {})
  @options = options.merge({ :access_token => access_token })
end

Instance Method Details

#call(path, options = {}) ⇒ Object

Generic Graph call to lookup data for any path



14
15
16
# File 'lib/fbauth/graph.rb', line 14

def call(path, options = {})
  get "#{FB_GRAPH_URL}/#{path}", merged_options(options)
end

#publish_to_member_feed(uid, options) ⇒ Object

Post item to member’s wall

Available options: message, picture, link, name, caption, description


20
21
22
23
24
25
# File 'lib/fbauth/graph.rb', line 20

def publish_to_member_feed(uid, options)
  raise "access_token required" unless has_access_token?(options)
  if %w{staging production}.include? Rails.env
    post "#{FB_GRAPH_URL}/#{uid}/feed", merged_options(options)
  end
end