如何解析FbGraph帐户

时间:2011-05-05 20:33:44

标签: ruby-on-rails facebook facebook-graph-api

我在做:

me = FbGraph::User.new('me', :access_token => authentication.token); 
puts me.accounts.to_yaml 

返回:

--- !seq:FbGraph::Connection 
- !ruby/object:FbGraph::Page 
access_token: something_here
affiliation: 
artists_we_like: 
attire: 
awards: 
band_interests: 
band_members: 
bio: 
booking_agent: 
can_post: 
category: Food/beverages
checkin_count: 
company_overview: 
culinary_team: 
current_location: 
directed_by: 
endpoint: https://graph.facebook.com/foobar
... # and so forth

我如何解析这个以便我可以获得access_token?即“something_here”

puts me.accounts.access_token 

返回

undefined method `access_token' for #<FbGraph::Connection:0x00000100dab938>

另一方面。

puts me.accounts.inspect

返回:

[#<FbGraph::Page:0x00000103738120 @identifier="foobar", @endpoint="https://graph.facebook.com/foobar", @access_token="something_here", @name="foobar", @username=nil, @category="Food/beverages", @like_count=nil, @affiliation=nil, @artists_we_like=nil, @attire=nil, @awards=nil, @band_interests=nil, @band_members=nil, @bio=nil, @booking_agent=nil, @can_post=nil, @company_overview=nil, @culinary_team=nil, @current_location=nil, @directed_by=nil, @features=nil, @general_info=nil, @general_manager=nil, @genre=nil, @hometown=nil, @influences=nil, @is_community_page=nil, @link=nil, @location=nil, @mission=nil, @mpg=nil, @personal_info=nil, @personal_interests=nil, @phone=nil, @plot_outline=nil, @press_contact=nil, @price_range=nil, @produced_by=nil, @products=nil, @public_transit=nil, @record_label=nil, @screenplay_by=nil, @starring=nil, @studio=nil, @website=nil, @written_by=nil, @parking=[], @payment_options=[], @restaurant_services=[] 
....

任何人都知道如何实现这一目标?

1 个答案:

答案 0 :(得分:0)

哦,傻傻的我。

puts me.accounts.first.access_token

作品!