Skip to content

Commit

Permalink
Add support for New Retweets
Browse files Browse the repository at this point in the history
New methods on base:
 * retweet(id)     - Retweet a status
 * retweeted_by_me - Retweets in calling user's timeline
 * retweeted_to_me - Retweets by the calling user
 * retweets_of_me  - Retweets of the calling user
 * retweets(id)    - Up to first 100 retweets of a status
  • Loading branch information
ivey committed Dec 1, 2009
1 parent de821c4 commit a1a8345
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def status(id)
perform_get("/statuses/show/#{id}.json")
end

# Options: count
def retweets(id, query={ })
perform_get("/statuses/retweets/#{id}.json", :query => query)
end

# Options: in_reply_to_status_id
def update(status, query={})
perform_post("/statuses/update.json", :body => {:status => status}.merge(query))
Expand All @@ -47,10 +52,29 @@ def mentions(query={})
perform_get('/statuses/mentions.json', :query => query)
end

# Options: since_id, max_id, count, page
def retweeted_by_me(query={})
perform_get('/statuses/retweeted_by_me.json', :query => query)
end

# Options: since_id, max_id, count, page
def retweeted_to_me(query={})
perform_get('/statuses/retweeted_to_me.json', :query => query)
end

# Options: since_id, max_id, count, page
def retweets_of_me(query={})
perform_get('/statuses/retweets_of_me.json', :query => query)
end

def status_destroy(id)
perform_post("/statuses/destroy/#{id}.json")
end

def retweet(id)
perform_post("/statuses/retweet/#{id}.json")
end

# Options: id, user_id, screen_name, page
def friends(query={})
perform_get('/statuses/friends.json', :query => query)
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/retweet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"<a href=\"http://apiwiki.twitter.com/\" rel=\"nofollow\">API</a>","user":{"statuses_count":10372,"profile_sidebar_fill_color":"EADEAA","description":"CEO of Twitpay. Entrepreneur and Rubyist in South Alabama with a wife, a baby, 6 cats, and 3 companies.","following":false,"geo_enabled":true,"time_zone":"Central Time (US & Canada)","profile_sidebar_border_color":"D9B17E","verified":false,"profile_text_color":"333333","followers_count":1432,"url":"http://gweezlebur.com","profile_background_image_url":"http://a1.twimg.com/profile_background_images/3272966/twitterbg.jpg","friends_count":475,"profile_link_color":"9D582E","protected":false,"profile_background_tile":false,"created_at":"Sun Oct 29 04:50:26 +0000 2006","profile_image_url":"http://a1.twimg.com/profile_images/531315010/image_normal.jpg","location":"Bay Minette, AL (30.90 -87.78)","name":"Michael D. Ivey","notifications":false,"favourites_count":1164,"profile_background_color":"8B542B","id":10967,"utc_offset":-21600,"screen_name":"ivey"},"truncated":false,"created_at":"Tue Dec 01 15:10:14 +0000 2009","id":6237351983,"retweeted_status":{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"<a href=\"http://www.atebits.com/\" rel=\"nofollow\">Tweetie</a>","user":{"statuses_count":2978,"profile_sidebar_fill_color":"01090d","description":"found","following":true,"geo_enabled":true,"time_zone":"Mountain Time (US & Canada)","profile_sidebar_border_color":"393b45","verified":false,"profile_text_color":"393b45","followers_count":201,"url":"http://joyfultohear.com","profile_background_image_url":"http://a3.twimg.com/profile_background_images/54441565/dhcabin.jpg","friends_count":129,"profile_link_color":"565759","protected":false,"profile_background_tile":false,"created_at":"Wed Jan 24 21:36:55 +0000 2007","profile_image_url":"http://a1.twimg.com/profile_images/525158294/photo_normal.jpg","location":"Boulder","name":" \u0f58\u0f72\u0f0b\u0f63 (Jake Stetser)","notifications":false,"favourites_count":43,"profile_background_color":"000000","id":696373,"utc_offset":-25200,"screen_name":"jstetser"},"truncated":false,"created_at":"Tue Dec 01 13:44:57 +0000 2009","id":6235127466,"favorited":false,"text":"I'm not actually awake. My mind's on autopilot for food and I managed to take a detour along the way."},"favorited":false,"text":"RT @jstetser: I'm not actually awake. My mind's on autopilot for food and I managed to take a detour along the way."}
1 change: 1 addition & 0 deletions test/fixtures/retweeted_by_me.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/fixtures/retweeted_to_me.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/fixtures/retweets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"source":"web","retweeted_status":{"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"source":"web","favorited":false,"geo":null,"user":{"profile_sidebar_fill_color":"e0ff92","followers_count":5753,"description":"I'm told I'm somewhat disappointing in person.","screen_name":"Moltz","following":false,"time_zone":"Pacific Time (US & Canada)","friends_count":193,"profile_sidebar_border_color":"87bc44","favourites_count":6808,"profile_text_color":"000000","url":"http://www.moltz.net/~john","notifications":false,"statuses_count":7110,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/4257777/B9_Torsoe.jpg","profile_link_color":"0000ff","protected":false,"geo_enabled":false,"profile_background_tile":true,"created_at":"Thu Apr 05 19:33:29 +0000 2007","location":"Tacoma, WA USA","name":"John Moltz","profile_background_color":"FFFFFF","profile_image_url":"http://a1.twimg.com/profile_images/116992556/B9_Torsoe_normal.jpg","id":3551171,"verified":false,"utc_offset":-28800},"in_reply_to_screen_name":null,"created_at":"Mon Nov 30 05:07:13 +0000 2009","id":6192831130,"text":"Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},"favorited":false,"geo":null,"user":{"profile_sidebar_fill_color":"ffffff","followers_count":536,"description":"Whatever you are, I am too","screen_name":"josephholsten","following":true,"time_zone":"Central Time (US & Canada)","friends_count":207,"profile_sidebar_border_color":"000000","favourites_count":622,"profile_text_color":"000000","url":"http://josephholsten.com","notifications":false,"statuses_count":2961,"profile_background_image_url":"http://s.twimg.com/a/1259091217/images/themes/theme1/bg.png","profile_link_color":"000000","protected":false,"geo_enabled":false,"profile_background_tile":false,"created_at":"Sat Aug 11 20:51:55 +0000 2007","location":"Tulsa, OK","name":"josephholsten","profile_background_color":"cccccc","profile_image_url":"http://a1.twimg.com/profile_images/259813726/not-identity_normal.jpg","id":8129542,"verified":false,"utc_offset":-21600},"in_reply_to_screen_name":null,"created_at":"Mon Nov 30 15:35:01 +0000 2009","id":6204338434,"text":"RT @Moltz: Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"web","user":{"profile_sidebar_fill_color":"ffffff","followers_count":513,"description":"EVILLEST, GRUESOME.","following":true,"time_zone":"Caracas","friends_count":407,"profile_sidebar_border_color":"cccccc","notifications":false,"favourites_count":4040,"profile_text_color":"000000","url":"http://www.gesteves.com","statuses_count":4912,"profile_background_image_url":"http://s.twimg.com/a/1259630745/images/themes/theme1/bg.png","profile_link_color":"Bf0222","protected":false,"geo_enabled":true,"profile_background_tile":false,"created_at":"Thu Dec 07 15:43:41 +0000 2006","profile_image_url":"http://a3.twimg.com/profile_images/552516023/IMG_1276_-_Version_2_normal.jpg","location":"Not where I want to be.","name":"Guillermo Esteves","profile_background_color":"eeeeee","id":48243,"verified":false,"utc_offset":-14400,"screen_name":"gesteves"},"truncated":false,"created_at":"Mon Nov 30 13:51:48 +0000 2009","id":6201653331,"retweeted_status":{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"web","user":{"profile_sidebar_fill_color":"e0ff92","followers_count":5764,"description":"I'm told I'm somewhat disappointing in person.","following":true,"time_zone":"Pacific Time (US & Canada)","friends_count":192,"profile_sidebar_border_color":"87bc44","notifications":false,"favourites_count":6812,"profile_text_color":"000000","url":"http://www.moltz.net/~john","statuses_count":7113,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/4257777/B9_Torsoe.jpg","profile_link_color":"0000ff","protected":false,"geo_enabled":false,"profile_background_tile":true,"created_at":"Thu Apr 05 19:33:29 +0000 2007","profile_image_url":"http://a1.twimg.com/profile_images/116992556/B9_Torsoe_normal.jpg","location":"Tacoma, WA USA","name":"John Moltz","profile_background_color":"FFFFFF","id":3551171,"verified":false,"utc_offset":-28800,"screen_name":"Moltz"},"truncated":false,"created_at":"Mon Nov 30 05:07:13 +0000 2009","id":6192831130,"favorited":false,"text":"Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},"favorited":false,"text":"RT @Moltz: Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"<a href=\"http://apiwiki.twitter.com/\" rel=\"nofollow\">API</a>","user":{"friends_count":392,"profile_sidebar_fill_color":"252429","description":"Web guy, handsome fellow, etc.","following":false,"notifications":false,"time_zone":"Eastern Time (US & Canada)","favourites_count":6471,"profile_sidebar_border_color":"181A1E","geo_enabled":false,"profile_text_color":"666666","url":"http://favrd.textism.com/person/kyleridolfo","verified":false,"profile_background_image_url":"http://s.twimg.com/a/1259630745/images/themes/theme9/bg.gif","profile_link_color":"2FC2EF","protected":false,"profile_background_tile":false,"created_at":"Fri May 18 06:19:13 +0000 2007","profile_image_url":"http://a3.twimg.com/profile_images/293863947/IMG_0138th_normal.jpg","location":"Under your bed.","name":"Kyle Ridolfo","profile_background_color":"1A1B1F","followers_count":418,"id":6129732,"statuses_count":8608,"utc_offset":-18000,"screen_name":"kyleridolfo"},"truncated":false,"created_at":"Mon Nov 30 13:03:00 +0000 2009","id":6200584197,"retweeted_status":{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"web","user":{"friends_count":192,"profile_sidebar_fill_color":"e0ff92","description":"I'm told I'm somewhat disappointing in person.","following":false,"notifications":false,"time_zone":"Pacific Time (US & Canada)","favourites_count":6812,"profile_sidebar_border_color":"87bc44","geo_enabled":false,"profile_text_color":"000000","url":"http://www.moltz.net/~john","verified":false,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/4257777/B9_Torsoe.jpg","profile_link_color":"0000ff","protected":false,"profile_background_tile":true,"created_at":"Thu Apr 05 19:33:29 +0000 2007","profile_image_url":"http://a1.twimg.com/profile_images/116992556/B9_Torsoe_normal.jpg","location":"Tacoma, WA USA","name":"John Moltz","profile_background_color":"FFFFFF","followers_count":5764,"id":3551171,"statuses_count":7113,"utc_offset":-28800,"screen_name":"Moltz"},"truncated":false,"created_at":"Mon Nov 30 05:07:13 +0000 2009","id":6192831130,"favorited":false,"text":"Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},"favorited":false,"text":"RT @Moltz: Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"<a href=\"http://apiwiki.twitter.com/\" rel=\"nofollow\">API</a>","user":{"profile_sidebar_fill_color":"EADEAA","description":"CEO of Twitpay. Entrepreneur and Rubyist in South Alabama with a wife, a baby, 6 cats, and 3 companies.","following":false,"time_zone":"Central Time (US & Canada)","profile_sidebar_border_color":"D9B17E","followers_count":1432,"profile_text_color":"333333","url":"http://gweezlebur.com","profile_background_image_url":"http://a1.twimg.com/profile_background_images/3272966/twitterbg.jpg","favourites_count":1164,"profile_link_color":"9D582E","protected":false,"verified":false,"geo_enabled":true,"profile_background_tile":false,"created_at":"Sun Oct 29 04:50:26 +0000 2006","friends_count":475,"profile_image_url":"http://a1.twimg.com/profile_images/531315010/image_normal.jpg","location":"Bay Minette, AL (30.90 -87.78)","name":"Michael D. Ivey","notifications":false,"statuses_count":10372,"profile_background_color":"8B542B","id":10967,"utc_offset":-21600,"screen_name":"ivey"},"truncated":false,"created_at":"Mon Nov 30 12:55:49 +0000 2009","id":6200432951,"retweeted_status":{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"web","user":{"profile_sidebar_fill_color":"e0ff92","description":"I'm told I'm somewhat disappointing in person.","following":false,"time_zone":"Pacific Time (US & Canada)","profile_sidebar_border_color":"87bc44","followers_count":5763,"profile_text_color":"000000","url":"http://www.moltz.net/~john","profile_background_image_url":"http://a3.twimg.com/profile_background_images/4257777/B9_Torsoe.jpg","favourites_count":6812,"profile_link_color":"0000ff","protected":false,"verified":false,"geo_enabled":false,"profile_background_tile":true,"created_at":"Thu Apr 05 19:33:29 +0000 2007","friends_count":192,"profile_image_url":"http://a1.twimg.com/profile_images/116992556/B9_Torsoe_normal.jpg","location":"Tacoma, WA USA","name":"John Moltz","notifications":false,"statuses_count":7113,"profile_background_color":"FFFFFF","id":3551171,"utc_offset":-28800,"screen_name":"Moltz"},"truncated":false,"created_at":"Mon Nov 30 05:07:13 +0000 2009","id":6192831130,"favorited":false,"text":"Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},"favorited":false,"text":"RT @Moltz: Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"<a href=\"http://apiwiki.twitter.com/\" rel=\"nofollow\">API</a>","user":{"friends_count":568,"profile_sidebar_fill_color":"e0ff92","description":"Computer Science student. Editor at Neowin. Rabid Muse fan. Apple aficionado. Java & Objective-C amateur. Wearer of Chuck Taylors. High volume tweeter.","following":false,"notifications":false,"time_zone":"Wellington","favourites_count":1008,"profile_sidebar_border_color":"87bc44","geo_enabled":true,"profile_text_color":"000000","url":"http://favstar.fm/users/sam_symons","verified":false,"profile_background_image_url":"http://s.twimg.com/a/1259630745/images/themes/theme1/bg.png","profile_link_color":"0000ff","protected":false,"profile_background_tile":false,"created_at":"Sun Jan 04 02:00:05 +0000 2009","profile_image_url":"http://a3.twimg.com/profile_images/535236655/Screen_shot_2009-11-20_at_7.52.21_PM_normal.png","location":"Christchurch, New Zealand","name":"Sam Symons","profile_background_color":"9ae4e8","followers_count":605,"id":18592658,"statuses_count":12693,"utc_offset":43200,"screen_name":"sam_symons"},"truncated":false,"created_at":"Mon Nov 30 07:45:45 +0000 2009","id":6195631146,"retweeted_status":{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"web","user":{"friends_count":192,"profile_sidebar_fill_color":"e0ff92","description":"I'm told I'm somewhat disappointing in person.","following":false,"notifications":false,"time_zone":"Pacific Time (US & Canada)","favourites_count":6812,"profile_sidebar_border_color":"87bc44","geo_enabled":false,"profile_text_color":"000000","url":"http://www.moltz.net/~john","verified":false,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/4257777/B9_Torsoe.jpg","profile_link_color":"0000ff","protected":false,"profile_background_tile":true,"created_at":"Thu Apr 05 19:33:29 +0000 2007","profile_image_url":"http://a1.twimg.com/profile_images/116992556/B9_Torsoe_normal.jpg","location":"Tacoma, WA USA","name":"John Moltz","profile_background_color":"FFFFFF","followers_count":5764,"id":3551171,"statuses_count":7113,"utc_offset":-28800,"screen_name":"Moltz"},"truncated":false,"created_at":"Mon Nov 30 05:07:13 +0000 2009","id":6192831130,"favorited":false,"text":"Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},"favorited":false,"text":"RT @Moltz: Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"<a href=\"http://favstar.fm\" rel=\"nofollow\">Favstar.FM</a>","user":{"profile_sidebar_fill_color":"e0ff92","description":"Favstar.fm guy, web/iPhone dev, Husband, Father, collector of tower statuettes, lover of grilled cheese.","friends_count":343,"following":null,"time_zone":"Wellington","profile_sidebar_border_color":"87bc44","notifications":null,"favourites_count":2921,"statuses_count":9970,"profile_text_color":"000000","url":"http://favstar.fm/users/timhaines","profile_background_image_url":"http://a3.twimg.com/profile_background_images/2447849/black-wallpaper-bg.gif","geo_enabled":false,"profile_link_color":"0000ff","protected":false,"profile_background_tile":true,"created_at":"Wed Apr 09 13:39:15 +0000 2008","profile_image_url":"http://a1.twimg.com/profile_images/544117810/TimWeekend_bigger2_normal.png","location":"Wellington, New Zealand","name":"Tim Haines","verified":false,"profile_background_color":"9ae4e8","id":14341663,"utc_offset":43200,"followers_count":1962,"screen_name":"timhaines"},"truncated":false,"created_at":"Mon Nov 30 07:44:35 +0000 2009","id":6195613181,"retweeted_status":{"in_reply_to_screen_name":null,"geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"web","user":{"profile_sidebar_fill_color":"e0ff92","description":"I'm told I'm somewhat disappointing in person.","friends_count":192,"following":null,"time_zone":"Pacific Time (US & Canada)","profile_sidebar_border_color":"87bc44","notifications":null,"favourites_count":6812,"statuses_count":7113,"profile_text_color":"000000","url":"http://www.moltz.net/~john","profile_background_image_url":"http://a3.twimg.com/profile_background_images/4257777/B9_Torsoe.jpg","geo_enabled":false,"profile_link_color":"0000ff","protected":false,"profile_background_tile":true,"created_at":"Thu Apr 05 19:33:29 +0000 2007","profile_image_url":"http://a1.twimg.com/profile_images/116992556/B9_Torsoe_normal.jpg","location":"Tacoma, WA USA","name":"John Moltz","verified":false,"profile_background_color":"FFFFFF","id":3551171,"utc_offset":-28800,"followers_count":5764,"screen_name":"Moltz"},"truncated":false,"created_at":"Mon Nov 30 05:07:13 +0000 2009","id":6192831130,"favorited":false,"text":"Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."},"favorited":false,"text":"RT @Moltz: Personally, I won't be satisfied until a Buddhist monk lights himself on fire for web standards."}]
Loading

0 comments on commit a1a8345

Please sign in to comment.