Permalink
Browse files

Get currently logged in user's stream.

  • Loading branch information...
Waseem Ahmad authored and mmangino committed Mar 5, 2010
1 parent 74376ba commit 0b406b7d2efa0fb091458f55ef1198706fab12e8
Showing with 30 additions and 0 deletions.
  1. +23 −0 lib/facebooker/models/user.rb
  2. +7 −0 test/facebooker_test.rb
@@ -297,6 +297,17 @@ def albums
end
end
+ ###
+ # Retrieve user's facebook stream
+ # See http://wiki.developers.facebook.com/index.php/Stream.get for options
+ #
+
+ def stream(options = {})
+ @stream = session.post('facebook.stream.get', prepare_get_stream_options(options)) do |response|
+ response
+ end
+ end
+
def create_album(params)
@album = session.post('facebook.photos.createAlbum', params) {|response| Album.from_hash(response)}
end
@@ -718,5 +729,17 @@ def merge_aid(aid, uid)
(uid << 32) + (aid & 0xFFFFFFFF)
end
+ def prepare_get_stream_options(options)
+ opts = {}
+
+ opts[:viewer_id] = self.id
+ opts[:source_ids] = options[:source_ids] if options[:source_ids]
+ opts[:start_time] = options[:start_time].to_i if options[:start_time]
+ opts[:end_time] = options[:end_time].to_i if options[:end_time]
+ opts[:limit] = options[:limit] if options[:limit].is_a?(Integer)
+ opts[:metadata] = Facebooker.json_encode(options[:metadata]) if options[:metadata]
+ opts
+ end
+
end
end
View
@@ -273,6 +273,13 @@ def test_can_get_stream
assert_equal('The bbc home page', stream[:posts].first['message'])
end
+ def test_can_get_user_stream
+ expect_http_posts_with_responses(example_user_stream_xml)
+ stream = @session.user.stream
+ assert stream[:albums].empty?
+ assert_equal('The bbc home page', stream[:posts].first['message'])
+ end
+
def test_can_create_album
expect_http_posts_with_responses(example_new_album_xml)
assert_equal "My Empty Album", @session.user.create_album(:name => "My Empty Album", :location => "Limboland").name

0 comments on commit 0b406b7

Please sign in to comment.