diff --git a/lib/twitter/client/user.rb b/lib/twitter/client/user.rb index f64b004d3..360abed6b 100644 --- a/lib/twitter/client/user.rb +++ b/lib/twitter/client/user.rb @@ -238,7 +238,7 @@ def recommendations(options={}) format.to_s.downcase == 'xml' ? response['userrecommendations'] : response end - # Returns users the specified user can contribute to. + # Returns an array of users that the specified user can contribute to # # @see http://dev.twitter.com/docs/api/1/get/users/contributees # @rate_limited Yes @@ -275,6 +275,44 @@ def contributees(*args) end format.to_s.downcase == 'xml' ? response['users'] : response end + + # Returns an array of users who can contribute to the specified account + # + # @see http://dev.twitter.com/docs/api/1/get/users/contributors + # @rate_limited Yes + # @requires_authentication No unless requesting it from a protected user + # + # If getting this data of a protected user, you must authenticate (and be allowed to see that user). + # @response_format `json` + # @response_format `xml` + # @overload contributors(options={}) + # @param options [Hash] A customizable set of options. + # @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1. + # @return [Array] + # @example Return the authenticated user's contributors + # Twitter.contributors + ## @overload contributors(user, options={}) + # @param user [Integer, String] A Twitter user ID or screen name. + # @param options [Hash] A customizable set of options. + # @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1. + # @return [Array] + # @example Return users who can contribute to @sferik's account + # Twitter.contributors("sferik") + # Twitter.contributors(7505382) # Same as above + def contributors(*args) + options = {} + options.merge!(args.last.is_a?(Hash) ? args.pop : {}) + user = args.pop || get_screen_name + if user + merge_user_into_options!(user, options) + response = get('1/users/contributors', options) + else + response = get('1/users/contributors', options) + end + format.to_s.downcase == 'xml' ? response['users'] : response + end end end end diff --git a/spec/fixtures/contributors.json b/spec/fixtures/contributors.json new file mode 100644 index 000000000..128ebca17 --- /dev/null +++ b/spec/fixtures/contributors.json @@ -0,0 +1 @@ +[{"profile_sidebar_fill_color":"C0DFEC","protected":false,"id_str":"13","notifications":false,"profile_background_tile":false,"screen_name":"biz","name":"Biz Stone","display_url":"bizstone.com","listed_count":15392,"location":"San Francisco, CA","expanded_url":"http:\/\/www.bizstone.com","show_all_inline_media":true,"contributors_enabled":false,"following":false,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"0084B4","description":"Co-founder of Twitter, Inc.","profile_sidebar_border_color":"a8c7f7","url":"http:\/\/t.co\/bdlNWgB","time_zone":"Pacific Time (US & Canada)","status":{"id_str":"110109632814518272","in_reply_to_status_id":null,"truncated":false,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"\u003Ca href=\"http:\/\/flickr.com\/services\/twitter\/\" rel=\"nofollow\"\u003EFlickr\u003C\/a\u003E","created_at":"Sat Sep 03 21:59:16 +0000 2011","contributors":null,"retweeted":false,"retweet_count":4,"id":110109632814518272,"place":null,"text":"Cavallo Point Dandelion http:\/\/t.co\/nv0gcpL"},"default_profile_image":false,"statuses_count":4466,"profile_use_background_image":true,"verified":true,"favourites_count":869,"friends_count":530,"profile_background_color":"022330","is_translator":false,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme15\/bg.png","created_at":"Tue Mar 21 20:51:43 +0000 2006","followers_count":1765283,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"default_profile":false,"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme15\/bg.png","id":13,"profile_text_color":"333333","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/513819852\/biz_stone_normal.jpg","profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/513819852\/biz_stone_normal.jpg"},{"profile_sidebar_fill_color":"454A43","protected":false,"id_str":"20","notifications":false,"profile_background_tile":true,"screen_name":"ev","name":"Evan Williams","display_url":"evhead.com","listed_count":17223,"location":"San Francisco, CA, US","expanded_url":"http:\/\/evhead.com","show_all_inline_media":true,"contributors_enabled":false,"following":false,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"A8AB9A","description":"Farm boy from Nebraska. Husband and father. Co-founder of Twitter. Partner at @ObviousCorp","profile_sidebar_border_color":"E23912","url":"http:\/\/t.co\/C2HZiQ4","time_zone":"Pacific Time (US & Canada)","status":{"id_str":"109843207965261824","in_reply_to_status_id":109841684006838272,"truncated":false,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":"109841684006838272","geo":null,"in_reply_to_screen_name":"chrissyteigen","in_reply_to_user_id_str":"39364684","coordinates":null,"in_reply_to_user_id":39364684,"source":"\u003Ca href=\"http:\/\/twitter.com\/#!\/download\/iphone\" rel=\"nofollow\"\u003ETwitter for iPhone\u003C\/a\u003E","created_at":"Sat Sep 03 04:20:36 +0000 2011","contributors":null,"retweeted":false,"retweet_count":3,"id":109843207965261824,"place":null,"text":"@chrissyteigen Well, at least you didn't want fried chicken and potato salad. Just saw this today: http:\/\/t.co\/hO4eIrl"},"default_profile_image":false,"statuses_count":6316,"profile_use_background_image":true,"verified":true,"favourites_count":1852,"friends_count":1346,"profile_background_color":"D4BEA7","is_translator":false,"default_profile":false,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/313094643\/COLOURlovers.com-Indecent_Exposure-.png","created_at":"Tue Mar 21 21:02:31 +0000 2006","followers_count":1386646,"entities":{"user_mentions":[{"name":"Obvious Corporation","screen_name":"obviouscorp","id_str":"322904764","indices":[78,90],"id":322904764}],"urls":[],"hashtags":[]},"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/313094643\/COLOURlovers.com-Indecent_Exposure-.png","id":20,"profile_text_color":"C3B7A1","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1275356729\/evedit0xr_2__1__normal.jpg","profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/1275356729\/evedit0xr_2__1__normal.jpg"},{"profile_sidebar_fill_color":"e0ff92","protected":false,"id_str":"822571","notifications":false,"profile_background_tile":false,"screen_name":"SG","name":"Sean Garrett","display_url":null,"listed_count":403,"location":"San Francisco","expanded_url":null,"show_all_inline_media":true,"contributors_enabled":false,"following":false,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"0000ff","description":"Ephemeral whinging aspects. Twitter, Inc. comms.","profile_sidebar_border_color":"87bc44","url":null,"time_zone":"Pacific Time (US & Canada)","status":{"id_str":"110015226308591616","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETwitter for iPhone\u003C\/a\u003E","created_at":"Sat Sep 03 15:44:08 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":110015226308591616,"place":null,"text":"Looking forward to the quirky infographic on the growth of quirky infigraphics."},"default_profile_image":false,"default_profile":false,"statuses_count":3436,"profile_use_background_image":true,"verified":false,"favourites_count":94,"friends_count":961,"profile_background_color":"9ae4e8","is_translator":false,"profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/25315274\/07-05-2003__44.jpg","created_at":"Thu Mar 08 18:38:33 +0000 2007","followers_count":15629,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/25315274\/07-05-2003__44.jpg","id":822571,"profile_text_color":"000000","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1041950033\/capt.80e1b2df11e243c0b9c78f70a49a8394-80e1b2df11e243c0b9c78f70a49a8394-0_normal.jpg","profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/1041950033\/capt.80e1b2df11e243c0b9c78f70a49a8394-80e1b2df11e243c0b9c78f70a49a8394-0_normal.jpg"},{"profile_sidebar_fill_color":"FFF7CC","protected":false,"id_str":"7694352","notifications":false,"profile_background_tile":true,"screen_name":"cpen","name":"Carolyn Penner","display_url":"cpen.posterous.com","listed_count":296,"location":"San Francisco","expanded_url":"http:\/\/cpen.posterous.com\/","show_all_inline_media":true,"contributors_enabled":true,"following":false,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"3851de","description":"twitter comms. mobile geek. laughs easily. talks loudly. and, according to @sg, the she in that's what she said","profile_sidebar_border_color":"F2E195","url":"http:\/\/t.co\/sWhRERk","time_zone":"Pacific Time (US & Canada)","status":{"id_str":"110109700942598144","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"\u003Ca href=\"http:\/\/twitter.com\/#!\/download\/iphone\" rel=\"nofollow\"\u003ETwitter for iPhone\u003C\/a\u003E","created_at":"Sat Sep 03 21:59:33 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":110109700942598144,"place":null,"text":"Lots of people in white today. Like, all white. #LaborDayCountdown"},"default_profile_image":false,"statuses_count":6231,"profile_use_background_image":true,"verified":false,"favourites_count":446,"friends_count":384,"profile_background_color":"BADFCD","is_translator":false,"default_profile":false,"profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/269139380\/sunset_benches.jpg","created_at":"Tue Jul 24 20:43:20 +0000 2007","followers_count":8505,"entities":{"user_mentions":[{"name":"Sean Garrett","screen_name":"SG","id_str":"822571","indices":[75,78],"id":822571}],"urls":[],"hashtags":[]},"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/269139380\/sunset_benches.jpg","id":7694352,"profile_text_color":"0C3E53","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1054499775\/profile2_normal.png","profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/1054499775\/profile2_normal.png"},{"default_profile":true,"profile_sidebar_fill_color":"DDEEF6","protected":false,"id_str":"14013722","notifications":null,"profile_background_tile":false,"screen_name":"mgrooves","name":"Matt Graves","display_url":null,"listed_count":186,"location":"San Francisco","expanded_url":null,"show_all_inline_media":true,"contributors_enabled":true,"following":null,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"0084B4","description":"twitter comms. lover of loud music and louder laughs.","profile_sidebar_border_color":"C0DEED","url":null,"time_zone":"Pacific Time (US & Canada)","status":{"id_str":"108792113889689600","in_reply_to_status_id":108715659239759872,"truncated":false,"favorited":false,"in_reply_to_status_id_str":"108715659239759872","geo":{"type":"Point","coordinates":[39.47795653,-119.82139879]},"in_reply_to_screen_name":"willotoons","in_reply_to_user_id_str":"772386","coordinates":{"type":"Point","coordinates":[-119.82139879,39.47795653]},"in_reply_to_user_id":772386,"source":"\u003Ca href=\"http:\/\/twitter.com\/#!\/download\/iphone\" rel=\"nofollow\"\u003ETwitter for iPhone\u003C\/a\u003E","created_at":"Wed Aug 31 06:43:55 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":108792113889689600,"place":{"name":"Reno","attributes":{},"full_name":"Reno, NV","url":"http:\/\/api.twitter.com\/1\/geo\/id\/4b25aded08900fd8.json","country_code":"US","bounding_box":{"type":"Polygon","coordinates":[[[-119.943728,39.416409],[-119.723736,39.416409],[-119.723736,39.693608],[-119.943728,39.693608]]]},"place_type":"city","country":"United States","id":"4b25aded08900fd8"},"text":"@willotoons @sfbg Good to know where you stand on the boobs v. butts issue. #important"},"default_profile_image":false,"statuses_count":3805,"profile_use_background_image":true,"verified":false,"favourites_count":193,"friends_count":857,"profile_background_color":"C0DEED","is_translator":false,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","created_at":"Tue Feb 26 17:06:58 +0000 2008","followers_count":4613,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"follow_request_sent":null,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","id":14013722,"profile_text_color":"333333","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1230241496\/Photo_on_2011-01-30_at_13.57__2_normal.jpg","profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/1230241496\/Photo_on_2011-01-30_at_13.57__2_normal.jpg"},{"profile_sidebar_fill_color":"F6F6F6","protected":false,"id_str":"16259374","notifications":false,"profile_background_tile":false,"screen_name":"jodiolson","name":"jodiolson","display_url":null,"listed_count":77,"location":"San Francisco","expanded_url":null,"show_all_inline_media":true,"contributors_enabled":false,"following":false,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"038543","description":"Twitter PR, mother, cook and aspiring gardener. Authentic but unverified.","profile_sidebar_border_color":"EEEEEE","url":null,"time_zone":"Pacific Time (US & Canada)","status":{"id_str":"109334062912638976","in_reply_to_status_id":null,"truncated":false,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"web","created_at":"Thu Sep 01 18:37:26 +0000 2011","contributors":null,"retweeted":false,"retweet_count":1,"id":109334062912638976,"place":null,"text":"A note from @jack to Twitter developers: http:\/\/t.co\/rWZ2TpE"},"default_profile_image":false,"default_profile":false,"statuses_count":1395,"profile_use_background_image":true,"verified":false,"favourites_count":14,"friends_count":596,"profile_background_color":"ACDED6","is_translator":false,"profile_background_image_url":"http:\/\/a1.twimg.com\/images\/themes\/theme18\/bg.gif","created_at":"Fri Sep 12 17:26:39 +0000 2008","followers_count":2907,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme18\/bg.gif","id":16259374,"profile_text_color":"333333","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/125848090\/JO_lisbon_normal_normal.jpg","profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/125848090\/JO_lisbon_normal_normal.jpg"},{"follow_request_sent":null,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/189647945\/xd9f362b4c1859de155db40b6a282d8d.jpg","protected":false,"notifications":null,"profile_text_color":"8C94A2","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1224057555\/photo-31_normal.jpeg","screen_name":"jennadawn","name":"jenna","profile_sidebar_fill_color":"424c55","location":"San Francisco ","id_str":"16739704","following":null,"profile_background_tile":false,"utc_offset":-28800,"description":"An Alaskan realizing the merit of urbanism via SF. Those who think idealism is naive only care to neglect. ","display_url":null,"listed_count":842,"url":null,"expanded_url":null,"show_all_inline_media":true,"contributors_enabled":false,"geo_enabled":true,"profile_link_color":"8cb2bd","status":{"contributors":null,"retweeted":false,"retweet_count":0,"id_str":"109474557777281024","in_reply_to_status_id":null,"truncated":false,"geo":null,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"coordinates":null,"source":"\u003Ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003ETwitter for Android\u003C\/a\u003E","created_at":"Fri Sep 02 03:55:44 +0000 2011","in_reply_to_screen_name":null,"id":109474557777281024,"in_reply_to_user_id_str":null,"place":null,"in_reply_to_user_id":null,"text":"My special friends. http:\/\/t.co\/5JqNrmC"},"profile_sidebar_border_color":"8cb2bd","time_zone":"Pacific Time (US & Canada)","default_profile_image":false,"statuses_count":1609,"profile_use_background_image":true,"created_at":"Tue Oct 14 15:31:55 +0000 2008","entities":{"hashtags":[],"user_mentions":[],"urls":[]},"lang":"en","verified":false,"favourites_count":43,"friends_count":489,"profile_background_color":"ffffff","id":16739704,"is_translator":true,"default_profile":false,"profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/189647945\/xd9f362b4c1859de155db40b6a282d8d.jpg","followers_count":308123,"profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/1224057555\/photo-31_normal.jpeg"},{"profile_sidebar_fill_color":"FFC36E","protected":false,"id_str":"145727626","notifications":null,"profile_background_tile":true,"screen_name":"juliedelcarlo","name":"Julie Del Carlo","display_url":null,"listed_count":46,"location":"","expanded_url":null,"show_all_inline_media":true,"contributors_enabled":false,"following":null,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"DD4969","description":"","profile_sidebar_border_color":"F8F2E6","url":null,"time_zone":"Pacific Time (US & Canada)","status":{"id_str":"108622547423199232","in_reply_to_status_id":null,"truncated":false,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"\u003Ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003ETwitter for Android\u003C\/a\u003E","created_at":"Tue Aug 30 19:30:08 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":108622547423199232,"place":null,"text":"A very happy birthday to @che! #francisco http:\/\/t.co\/LUjIvI6"},"default_profile_image":false,"default_profile":false,"statuses_count":402,"profile_use_background_image":true,"verified":false,"favourites_count":8,"friends_count":586,"profile_background_color":"FBC2CE","is_translator":false,"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/319117928\/xbad02b8c30148db3a7d53570a0acdbf.png","created_at":"Wed May 19 18:32:50 +0000 2010","followers_count":3823,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"follow_request_sent":null,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/319117928\/xbad02b8c30148db3a7d53570a0acdbf.png","id":145727626,"profile_text_color":"5A4A37","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1441125224\/me_in_nyc_normal","profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/1441125224\/me_in_nyc_normal"},{"profile_sidebar_fill_color":"F7F9F9","protected":false,"id_str":"22824309","notifications":false,"profile_background_tile":true,"screen_name":"RachaelRad","name":"Rachael Horwitz","display_url":null,"listed_count":38,"location":"San Francisco, CA","expanded_url":null,"show_all_inline_media":true,"contributors_enabled":false,"following":false,"geo_enabled":false,"utc_offset":-28800,"profile_link_color":"000807","description":"Twitter Communications. Short person. Loud voice. More than just a pizzabagel. ","profile_sidebar_border_color":"EBD98D","url":null,"time_zone":"Pacific Time (US & Canada)","status":{"id_str":"110116509141045249","in_reply_to_status_id":null,"truncated":false,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"\u003Ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003ETwitter for Android\u003C\/a\u003E","created_at":"Sat Sep 03 22:26:36 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":110116509141045249,"place":null,"text":"Greetings from Oregon! http:\/\/t.co\/slpi8xr"},"default_profile_image":false,"statuses_count":2325,"profile_use_background_image":true,"default_profile":false,"verified":false,"favourites_count":51,"friends_count":682,"profile_background_color":"665147","is_translator":false,"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/315104167\/x9d3c16ade13b57b2abe466f3b154311.jpg","created_at":"Wed Mar 04 19:57:26 +0000 2009","followers_count":869,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/315104167\/x9d3c16ade13b57b2abe466f3b154311.jpg","id":22824309,"profile_text_color":"090700","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1408115265\/186227_587309531_8155668_n_normal.jpg","profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1408115265\/186227_587309531_8155668_n_normal.jpg"},{"profile_sidebar_fill_color":"fdfcfc","protected":false,"id_str":"3446291","notifications":null,"profile_background_tile":true,"screen_name":"rbremer","name":"Rachel Bremer","display_url":null,"listed_count":36,"location":"London","expanded_url":null,"show_all_inline_media":true,"contributors_enabled":false,"following":null,"geo_enabled":false,"utc_offset":0,"profile_link_color":"0000ff","description":"European communications manager for Twitter. That's enough for now.","profile_sidebar_border_color":"e6e9e2","url":null,"time_zone":"London","status":{"id_str":"109924107214258176","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"\u003Ca href=\"http:\/\/twitter.com\/#!\/download\/iphone\" rel=\"nofollow\"\u003ETwitter for iPhone\u003C\/a\u003E","created_at":"Sat Sep 03 09:42:04 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":109924107214258176,"place":null,"text":"On our way to Burghley for a day of horsey stuff..."},"default_profile_image":false,"statuses_count":2556,"profile_use_background_image":true,"verified":false,"favourites_count":31,"friends_count":557,"profile_background_color":"9ae4e8","is_translator":false,"profile_background_image_url":"http:\/\/a2.twimg.com\/profile_background_images\/4036889\/Twitter.jpg","created_at":"Wed Apr 04 18:09:44 +0000 2007","followers_count":1666,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"default_profile":false,"follow_request_sent":null,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/4036889\/Twitter.jpg","id":3446291,"profile_text_color":"000000","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1370853870\/RYB_headshot_sm_normal.jpg","profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/1370853870\/RYB_headshot_sm_normal.jpg"},{"profile_sidebar_fill_color":"DDFFCC","protected":false,"id_str":"14769591","notifications":false,"profile_background_tile":true,"screen_name":"foxycar","name":"Lynn Fox","display_url":null,"listed_count":198,"location":"","expanded_url":null,"show_all_inline_media":true,"contributors_enabled":false,"following":false,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"0084B4","description":"Twitter Comms. OH'ing myself.","default_profile":false,"profile_sidebar_border_color":"BDDCAD","url":null,"time_zone":"Pacific Time (US & Canada)","status":{"id_str":"110023646487117824","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"geo":null,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":null,"in_reply_to_user_id":null,"source":"web","created_at":"Sat Sep 03 16:17:36 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":110023646487117824,"place":null,"text":"Just showed \"Who's on first?\" to the boys. Classic."},"default_profile_image":false,"statuses_count":4058,"profile_use_background_image":true,"verified":false,"favourites_count":44,"friends_count":969,"profile_background_color":"9AE4E8","is_translator":false,"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/143745093\/Photo_102.jpg","created_at":"Wed May 14 05:26:31 +0000 2008","followers_count":2702,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/143745093\/Photo_102.jpg","id":14769591,"profile_text_color":"333333","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1134096793\/bio_photo_small_normal.jpg","profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/1134096793\/bio_photo_small_normal.jpg"},{"profile_sidebar_fill_color":"e0ff92","protected":false,"id_str":"14589956","notifications":false,"profile_background_tile":true,"screen_name":"kh","name":"kristen","display_url":"about.me\/kristenhawley","listed_count":57,"location":"San Francisco","expanded_url":"http:\/\/about.me\/kristenhawley","show_all_inline_media":true,"contributors_enabled":false,"following":false,"geo_enabled":true,"utc_offset":-28800,"profile_link_color":"B21515","description":"I'm a fun girl! Also, communications at Twitter","default_profile":false,"profile_sidebar_border_color":"2DA530","url":"http:\/\/t.co\/B6brkVp","time_zone":"Pacific Time (US & Canada)","status":{"id_str":"110115169379684353","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"geo":{"type":"Point","coordinates":[38.47005683,-123.01459763]},"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"coordinates":{"type":"Point","coordinates":[-123.01459763,38.47005683]},"in_reply_to_user_id":null,"source":"\u003Ca href=\"http:\/\/twitter.com\/#!\/download\/iphone\" rel=\"nofollow\"\u003ETwitter for iPhone\u003C\/a\u003E","created_at":"Sat Sep 03 22:21:16 +0000 2011","contributors":null,"retweeted":false,"retweet_count":0,"id":110115169379684353,"place":{"name":"Monte Rio","attributes":{},"full_name":"Monte Rio, CA","url":"http:\/\/api.twitter.com\/1\/geo\/id\/aa352d4b3a8983c0.json","country_code":"US","bounding_box":{"type":"Polygon","coordinates":[[[-123.03198,38.455777],[-122.991321,38.455777],[-122.991321,38.476978],[-123.03198,38.476978]]]},"place_type":"city","country":"United States","id":"aa352d4b3a8983c0"},"text":"Happy where I am, happy where I am going."},"default_profile_image":false,"statuses_count":3946,"profile_use_background_image":true,"verified":false,"favourites_count":210,"friends_count":230,"profile_background_color":"9ae4e8","is_translator":false,"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/8116121\/Picture_1.png","created_at":"Tue Apr 29 20:06:27 +0000 2008","followers_count":1825,"entities":{"user_mentions":[],"urls":[],"hashtags":[]},"follow_request_sent":false,"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/8116121\/Picture_1.png","id":14589956,"profile_text_color":"000000","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1352279358\/twitterpic_normal.jpg","profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/1352279358\/twitterpic_normal.jpg"}] \ No newline at end of file diff --git a/spec/fixtures/contributors.xml b/spec/fixtures/contributors.xml new file mode 100644 index 000000000..d05fadbb9 --- /dev/null +++ b/spec/fixtures/contributors.xml @@ -0,0 +1,807 @@ + + + + 13 + Biz Stone + biz + San Francisco, CA + Co-founder of Twitter, Inc. + http://a0.twimg.com/profile_images/513819852/biz_stone_normal.jpg + https://si0.twimg.com/profile_images/513819852/biz_stone_normal.jpg + http://t.co/bdlNWgB + false + 1765282 + 022330 + 333333 + 0084B4 + C0DFEC + a8c7f7 + 530 + Tue Mar 21 20:51:43 +0000 2006 + 869 + -28800 + Pacific Time (US & Canada) + http://a0.twimg.com/images/themes/theme15/bg.png + https://si0.twimg.com/images/themes/theme15/bg.png + false + true + + true + true + + 4466 + en + false + + 15392 + true + false + false + http://www.bizstone.com + bizstone.com + + + + + + false + + Sat Sep 03 21:59:16 +0000 2011 + 110109632814518272 + Cavallo Point Dandelion http://t.co/nv0gcpL + <a href="http://flickr.com/services/twitter/" rel="nofollow">Flickr</a> + false + false + + + + 4 + false + + + + false + + + + + 20 + Evan Williams + ev + San Francisco, CA, US + Farm boy from Nebraska. Husband and father. Co-founder of Twitter. Partner at @ObviousCorp + http://a1.twimg.com/profile_images/1275356729/evedit0xr_2__1__normal.jpg + https://si0.twimg.com/profile_images/1275356729/evedit0xr_2__1__normal.jpg + http://t.co/C2HZiQ4 + false + 1386646 + D4BEA7 + C3B7A1 + A8AB9A + 454A43 + E23912 + 1346 + Tue Mar 21 21:02:31 +0000 2006 + 1852 + -28800 + Pacific Time (US & Canada) + http://a1.twimg.com/profile_background_images/313094643/COLOURlovers.com-Indecent_Exposure-.png + https://si0.twimg.com/profile_background_images/313094643/COLOURlovers.com-Indecent_Exposure-.png + true + true + false + true + true + false + 6316 + en + false + false + 17223 + true + false + false + http://evhead.com + evhead.com + + + + 322904764 + obviouscorp + Obvious Corporation + + + + + + false + + Sat Sep 03 04:20:36 +0000 2011 + 109843207965261824 + @chrissyteigen Well, at least you didn't want fried chicken and potato salad. Just saw this today: http://t.co/hO4eIrl + <a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a> + false + false + 109841684006838272 + 39364684 + chrissyteigen + 3 + false + + + + false + + + + + 822571 + Sean Garrett + SG + San Francisco + Ephemeral whinging aspects. Twitter, Inc. comms. + http://a3.twimg.com/profile_images/1041950033/capt.80e1b2df11e243c0b9c78f70a49a8394-80e1b2df11e243c0b9c78f70a49a8394-0_normal.jpg + https://si0.twimg.com/profile_images/1041950033/capt.80e1b2df11e243c0b9c78f70a49a8394-80e1b2df11e243c0b9c78f70a49a8394-0_normal.jpg + + false + 15629 + 9ae4e8 + 000000 + 0000ff + e0ff92 + 87bc44 + 961 + Thu Mar 08 18:38:33 +0000 2007 + 94 + -28800 + Pacific Time (US & Canada) + http://a0.twimg.com/profile_background_images/25315274/07-05-2003__44.jpg + https://si0.twimg.com/profile_background_images/25315274/07-05-2003__44.jpg + false + true + false + true + false + false + 3436 + en + false + false + 403 + true + false + false + + + + + + + + false + + Sat Sep 03 15:44:08 +0000 2011 + 110015226308591616 + Looking forward to the quirky infographic on the growth of quirky infigraphics. + <a href="http://twitter.com" rel="nofollow">Twitter for iPhone</a> + false + false + + + + 0 + false + + + + + + + + 7694352 + Carolyn Penner + cpen + San Francisco + twitter comms. mobile geek. laughs easily. talks loudly. and, according to @sg, the she in that's what she said + http://a2.twimg.com/profile_images/1054499775/profile2_normal.png + https://si0.twimg.com/profile_images/1054499775/profile2_normal.png + http://t.co/sWhRERk + false + 8505 + BADFCD + 0C3E53 + 3851de + FFF7CC + F2E195 + 384 + Tue Jul 24 20:43:20 +0000 2007 + 446 + -28800 + Pacific Time (US & Canada) + http://a0.twimg.com/profile_background_images/269139380/sunset_benches.jpg + https://si0.twimg.com/profile_background_images/269139380/sunset_benches.jpg + true + true + false + true + false + false + 6231 + en + true + false + 296 + true + false + false + http://cpen.posterous.com/ + cpen.posterous.com + + + + 822571 + SG + Sean Garrett + + + + + + false + + Sat Sep 03 21:59:33 +0000 2011 + 110109700942598144 + Lots of people in white today. Like, all white. #LaborDayCountdown + <a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a> + false + false + + + + 0 + false + + + + + + + + 14013722 + Matt Graves + mgrooves + San Francisco + twitter comms. lover of loud music and louder laughs. + http://a3.twimg.com/profile_images/1230241496/Photo_on_2011-01-30_at_13.57__2_normal.jpg + https://si0.twimg.com/profile_images/1230241496/Photo_on_2011-01-30_at_13.57__2_normal.jpg + + false + 4613 + C0DEED + 333333 + 0084B4 + DDEEF6 + C0DEED + 857 + Tue Feb 26 17:06:58 +0000 2008 + 193 + -28800 + Pacific Time (US & Canada) + http://a0.twimg.com/images/themes/theme1/bg.png + https://si0.twimg.com/images/themes/theme1/bg.png + false + true + + true + false + + 3805 + en + true + + 186 + true + true + false + + + + + + + + false + + Wed Aug 31 06:43:55 +0000 2011 + 108792113889689600 + @willotoons @sfbg Good to know where you stand on the boobs v. butts issue. #important + <a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a> + false + false + 108715659239759872 + 772386 + willotoons + 0 + false + + 39.47795653 -119.82139879 + + + 39.47795653 -119.82139879 + + + 4b25aded08900fd8 + Reno + Reno, NV + city + http://api.twitter.com/1/geo/id/4b25aded08900fd8.json + + + 39.416409 -119.943728 39.416409 -119.723736 39.693608 -119.723736 39.693608 -119.943728 + + United States + + + + + + 16259374 + jodiolson + jodiolson + San Francisco + Twitter PR, mother, cook and aspiring gardener. Authentic but unverified. + http://a2.twimg.com/profile_images/125848090/JO_lisbon_normal_normal.jpg + https://si0.twimg.com/profile_images/125848090/JO_lisbon_normal_normal.jpg + + false + 2907 + ACDED6 + 333333 + 038543 + F6F6F6 + EEEEEE + 596 + Fri Sep 12 17:26:39 +0000 2008 + 14 + -28800 + Pacific Time (US & Canada) + http://a1.twimg.com/images/themes/theme18/bg.gif + https://si0.twimg.com/images/themes/theme18/bg.gif + false + true + false + true + false + false + 1395 + en + false + false + 77 + true + false + false + + + + + + + + false + + Thu Sep 01 18:37:26 +0000 2011 + 109334062912638976 + A note from @jack to Twitter developers: http://t.co/rWZ2TpE + web + false + false + + + + 1 + false + + + + false + + + + + 16739704 + jenna + jennadawn + San Francisco + An Alaskan realizing the merit of urbanism via SF. Those who think idealism is naive only care to neglect. + http://a3.twimg.com/profile_images/1224057555/photo-31_normal.jpeg + https://si0.twimg.com/profile_images/1224057555/photo-31_normal.jpeg + + false + 308123 + ffffff + 8C94A2 + 8cb2bd + 424c55 + 8cb2bd + 489 + Tue Oct 14 15:31:55 +0000 2008 + 43 + -28800 + Pacific Time (US & Canada) + http://a0.twimg.com/profile_background_images/189647945/xd9f362b4c1859de155db40b6a282d8d.jpg + https://si0.twimg.com/profile_background_images/189647945/xd9f362b4c1859de155db40b6a282d8d.jpg + false + true + false + true + false + false + 1609 + en + false + false + 842 + true + false + false + + + + + + + + true + + Fri Sep 02 03:55:44 +0000 2011 + 109474557777281024 + My special friends. http://t.co/5JqNrmC + <a href="http://twitter.com/download/android" rel="nofollow">Twitter for Android</a> + false + false + + + + 0 + false + + + + false + + + + + 145727626 + Julie Del Carlo + juliedelcarlo + + + http://a1.twimg.com/profile_images/1441125224/me_in_nyc_normal + https://si0.twimg.com/profile_images/1441125224/me_in_nyc_normal + + false + 3823 + FBC2CE + 5A4A37 + DD4969 + FFC36E + F8F2E6 + 586 + Wed May 19 18:32:50 +0000 2010 + 8 + -28800 + Pacific Time (US & Canada) + http://a3.twimg.com/profile_background_images/319117928/xbad02b8c30148db3a7d53570a0acdbf.png + https://si0.twimg.com/profile_background_images/319117928/xbad02b8c30148db3a7d53570a0acdbf.png + true + true + + true + false + + 402 + en + false + + 46 + true + false + false + + + + + + + + false + + Tue Aug 30 19:30:08 +0000 2011 + 108622547423199232 + A very happy birthday to @che! #francisco http://t.co/LUjIvI6 + <a href="http://twitter.com/download/android" rel="nofollow">Twitter for Android</a> + false + false + + + + 0 + false + + + + false + + + + + 22824309 + Rachael Horwitz + RachaelRad + San Francisco, CA + Twitter Communications. Short person. Loud voice. More than just a pizzabagel. + http://a0.twimg.com/profile_images/1408115265/186227_587309531_8155668_n_normal.jpg + https://si0.twimg.com/profile_images/1408115265/186227_587309531_8155668_n_normal.jpg + + false + 868 + 665147 + 090700 + 000807 + F7F9F9 + EBD98D + 682 + Wed Mar 04 19:57:26 +0000 2009 + 51 + -28800 + Pacific Time (US & Canada) + http://a3.twimg.com/profile_background_images/315104167/x9d3c16ade13b57b2abe466f3b154311.jpg + https://si0.twimg.com/profile_background_images/315104167/x9d3c16ade13b57b2abe466f3b154311.jpg + true + true + false + false + false + false + 2325 + en + false + false + 38 + true + false + false + + + + + + + + false + + Sat Sep 03 22:26:36 +0000 2011 + 110116509141045249 + Greetings from Oregon! http://t.co/slpi8xr + <a href="http://twitter.com/download/android" rel="nofollow">Twitter for Android</a> + false + false + + + + 0 + false + + + + false + + + + + 3446291 + Rachel Bremer + rbremer + London + European communications manager for Twitter. That's enough for now. + http://a2.twimg.com/profile_images/1370853870/RYB_headshot_sm_normal.jpg + https://si0.twimg.com/profile_images/1370853870/RYB_headshot_sm_normal.jpg + + false + 1666 + 9ae4e8 + 000000 + 0000ff + fdfcfc + e6e9e2 + 557 + Wed Apr 04 18:09:44 +0000 2007 + 31 + 0 + London + http://a2.twimg.com/profile_background_images/4036889/Twitter.jpg + https://si0.twimg.com/profile_background_images/4036889/Twitter.jpg + true + true + false + false + false + false + 2556 + en + false + false + 36 + true + false + false + + + + + + + + false + + Sat Sep 03 09:42:04 +0000 2011 + 109924107214258176 + On our way to Burghley for a day of horsey stuff... + <a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a> + false + false + + + + 0 + false + + + + + + + + 14769591 + Lynn Fox + foxycar + + Twitter Comms. OH'ing myself. + http://a2.twimg.com/profile_images/1134096793/bio_photo_small_normal.jpg + https://si0.twimg.com/profile_images/1134096793/bio_photo_small_normal.jpg + + false + 2702 + 9AE4E8 + 333333 + 0084B4 + DDFFCC + BDDCAD + 969 + Wed May 14 05:26:31 +0000 2008 + 44 + -28800 + Pacific Time (US & Canada) + http://a3.twimg.com/profile_background_images/143745093/Photo_102.jpg + https://si0.twimg.com/profile_background_images/143745093/Photo_102.jpg + true + true + false + true + false + false + 4058 + en + false + false + 198 + true + false + false + + + + + + + + false + + Sat Sep 03 16:17:36 +0000 2011 + 110023646487117824 + Just showed "Who's on first?" to the boys. Classic. + web + false + false + + + + 0 + false + + + + + + + + 14589956 + kristen + kh + San Francisco + I'm a fun girl! Also, communications at Twitter + http://a2.twimg.com/profile_images/1352279358/twitterpic_normal.jpg + https://si0.twimg.com/profile_images/1352279358/twitterpic_normal.jpg + http://t.co/B6brkVp + false + 1825 + 9ae4e8 + 000000 + B21515 + e0ff92 + 2DA530 + 230 + Tue Apr 29 20:06:27 +0000 2008 + 210 + -28800 + Pacific Time (US & Canada) + http://a3.twimg.com/profile_background_images/8116121/Picture_1.png + https://si0.twimg.com/profile_background_images/8116121/Picture_1.png + true + true + + true + false + + 3946 + en + false + + 57 + true + false + false + http://about.me/kristenhawley + about.me/kristenhawley + + + + + + false + + Sat Sep 03 22:21:16 +0000 2011 + 110115169379684353 + Happy where I am, happy where I am going. + <a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a> + false + false + + + + 0 + false + + 38.47005683 -123.01459763 + + + 38.47005683 -123.01459763 + + + aa352d4b3a8983c0 + Monte Rio + Monte Rio, CA + city + http://api.twitter.com/1/geo/id/aa352d4b3a8983c0.json + + + 38.455777 -123.03198 38.455777 -122.991321 38.476978 -122.991321 38.476978 -123.03198 + + United States + + + + + diff --git a/spec/twitter/client/activity_spec.rb b/spec/twitter/client/activity_spec.rb new file mode 100644 index 000000000..b0b72edd1 --- /dev/null +++ b/spec/twitter/client/activity_spec.rb @@ -0,0 +1,51 @@ +=begin +require 'helper' + +describe Twitter::Client do + context ".new" do + before do + @client = Twitter::Client.new + end + + describe ".about_me" do + + before do + stub_get("i/activity/about_me.json"). + to_return(:body => fixture("about_me.json"), :headers => {:content_type => "application/json; charset=utf-8"}) + end + + it "should get the correct resource" do + @client.about_me + a_get("i/activity/about_me.json"). + should have_been_made + end + + it "should return activity about me" do + about_me = @client.about_me + about_me.first.action.should == "mention" + end + + end + + describe ".by_friends" do + + before do + stub_get("i/activity/by_friends.json"). + to_return(:body => fixture("by_friends.json"), :headers => {:content_type => "application/json; charset=utf-8"}) + end + + it "should get the correct resource" do + @client.by_friends + a_get("i/activity/by_friends.json"). + should have_been_made + end + + it "should return activity by friends" do + by_friends = @client.by_friends + by_friends.first.action.should == "favorite" + end + + end + end +end +=end diff --git a/spec/twitter/client/user_spec.rb b/spec/twitter/client/user_spec.rb index b5fea52cf..09e124764 100644 --- a/spec/twitter/client/user_spec.rb +++ b/spec/twitter/client/user_spec.rb @@ -484,6 +484,54 @@ end end end + + describe ".contributors" do + + context "with a screen name passed" do + + before do + stub_get("1/users/contributors.#{format}"). + with(:query => {:screen_name => "sferik"}). + to_return(:body => fixture("contributors.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + end + + it "should get the correct resource" do + @client.contributors("sferik") + a_get("1/users/contributors.#{format}"). + with(:query => {:screen_name => "sferik"}). + should have_been_made + end + + it "should return a user's contributors" do + contributors = @client.contributors("sferik") + contributors.should be_an Array + contributors.first.name.should == "Biz Stone" + end + end + + context "without arguments passed" do + + before do + @client.stub!(:get_screen_name).and_return('sferik') + stub_get("1/users/contributors.#{format}"). + with(:query => {:screen_name => "sferik"}). + to_return(:body => fixture("contributors.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + end + + it "should get the correct resource" do + @client.contributors + a_get("1/users/contributors.#{format}"). + with(:query => {:screen_name => "sferik"}). + should have_been_made + end + + it "should return a user's contributors" do + contributors = @client.contributors + contributors.should be_an Array + contributors.first.name.should == "Biz Stone" + end + end + end end end end