Class: Facebook::GraphApi

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook/graph_api.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ GraphApi

Returns a new instance of GraphApi.



13
14
15
16
17
# File 'lib/facebook/graph_api.rb', line 13

def initialize session
	@access_token = session[:access_token]
	log! 'GraphApi access_token', @access_token
	@fb_api =  ::Facebook.api.new(access_token)			
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



11
12
13
# File 'lib/facebook/graph_api.rb', line 11

def access_token
  @access_token
end

#fb_apiObject (readonly)

Returns the value of attribute fb_api.



11
12
13
# File 'lib/facebook/graph_api.rb', line 11

def fb_api
  @fb_api
end

Class Method Details

.clazzObject



23
24
25
# File 'lib/facebook/graph_api.rb', line 23

def self.clazz
	::Facebook.api
end

Instance Method Details

#apiObject



19
20
21
# File 'lib/facebook/graph_api.rb', line 19

def api
	@api ||= fb_api
end

#meObject

also see developers.facebook.com/docs/reference/fql/ The Facebook Query Language for more efficient complex queries Also enables Multi-query



31
32
33
# File 'lib/facebook/graph_api.rb', line 31

def me
  @me ||= ::Hashie::Mash.new api.get_object('me')
end

#my_friendsObject



42
43
44
45
# File 'lib/facebook/graph_api.rb', line 42

def my_friends
	# or fb.me.friends
  me.friends
end

#my_messagesObject



51
52
53
# File 'lib/facebook/graph_api.rb', line 51

def my_messages
  api.get_object "/me/statuses", "fields"=>"message"
end

#my_pictureObject



47
48
49
# File 'lib/facebook/graph_api.rb', line 47

def my_picture
	api.get_picture my_id
end

#post_on_wall(message) ⇒ Object

Post



57
58
59
# File 'lib/facebook/graph_api.rb', line 57

def post_on_wall message
  api.put_wall_post message
end