Class: Facebookdp::Base
- Inherits:
-
Object
- Object
- Facebookdp::Base
- Defined in:
- lib/facebookdp/base.rb
Instance Method Summary collapse
-
#friend_ids_and_names ⇒ Object
Get list of hash’s id and name keys for each of current_user’s friends.
-
#friend_info(fbid) ⇒ Object
Retrieve full information about a friend given their facebook id.
-
#friend_latest_statuses(unix_timestamp) ⇒ Object
Retrieve all statuses published by a friend since the date specified.
-
#friend_statuses(fbid, limit = 10) ⇒ Object
Retrieve last 10 statuses of a friend.
-
#friends(limit = 0, offset = 0) ⇒ Object
Get all information about all your friends.
-
#initialize(oauth2_access_token) ⇒ Base
constructor
A new instance of Base.
-
#my_account ⇒ Object
Return current user’s account information.
- #my_picture_url ⇒ Object
Constructor Details
#initialize(oauth2_access_token) ⇒ Base
Returns a new instance of Base.
3 4 5 |
# File 'lib/facebookdp/base.rb', line 3 def initialize(oauth2_access_token) @access_token = oauth2_access_token end |
Instance Method Details
#friend_ids_and_names ⇒ Object
Get list of hash’s id and name keys for each of current_user’s friends
18 19 20 |
# File 'lib/facebookdp/base.rb', line 18 def friend_ids_and_names @friend_ids ||= Crack::JSON.parse(get_request("/me/friends?fields=id,name"))['data'] end |
#friend_info(fbid) ⇒ Object
Retrieve full information about a friend given their facebook id
33 34 35 |
# File 'lib/facebookdp/base.rb', line 33 def friend_info(fbid) Crack::JSON.parse(get_request("/#{fbid}")) end |
#friend_latest_statuses(unix_timestamp) ⇒ Object
Retrieve all statuses published by a friend since the date specified. TODO: not tested yet
45 46 47 |
# File 'lib/facebookdp/base.rb', line 45 def friend_latest_statuses() Crack::JSON.parse(get_request("/#{fbid}/statuses?since=#{unix_timestamp}")) end |
#friend_statuses(fbid, limit = 10) ⇒ Object
Retrieve last 10 statuses of a friend. Pass in limit to control number of status returned
39 40 41 |
# File 'lib/facebookdp/base.rb', line 39 def friend_statuses(fbid, limit=10) Crack::JSON.parse(get_request("/#{fbid}/statuses?limit=#{limit}"))['data'] end |
#friends(limit = 0, offset = 0) ⇒ Object
Get all information about all your friends. Pass limit
23 24 25 26 27 28 29 30 |
# File 'lib/facebookdp/base.rb', line 23 def friends(limit=0, offset=0) if(limit<=0) @friends ||= Crack::JSON.parse(get_request("/me/friends"))['data'] else #TODO: this isn't working, not sure why @friends ||= Crack::JSON.parse(get_request("/me/friends?limit=#{limit}&offset=#{offset}"))['data'] end end |
#my_account ⇒ Object
Return current user’s account information
9 10 11 |
# File 'lib/facebookdp/base.rb', line 9 def my_account @my_account ||= Crack::JSON.parse(get_request("/me")) end |
#my_picture_url ⇒ Object
13 14 15 |
# File 'lib/facebookdp/base.rb', line 13 def my_picture_url @my_picture_url ||= "http://graph.facebook.com/#{my_account['id']}/picture" end |