diff --git a/History b/History index e8157fcd6..d3e8804a2 100644 --- a/History +++ b/History @@ -1,3 +1,5 @@ +0.7.4 - Novermber 16, 2009 + * Support for user search 0.7.3 - November 5, 2009 * Support for list_subscriptions from christospappas 0.7.2 - November 5, 2009 diff --git a/lib/twitter/base.rb b/lib/twitter/base.rb index 838fc566e..27d08bbb4 100644 --- a/lib/twitter/base.rb +++ b/lib/twitter/base.rb @@ -60,6 +60,12 @@ def followers(query={}) def user(id, query={}) perform_get("/users/show/#{id}.json", :query => query) end + + # Options: page, per_page + def user_search(q, query={}) + q = URI.escape(q) + perform_get("/users/search.json", :query => ({:q => q}.merge(query))) + end # Options: since, since_id, page def direct_messages(query={}) diff --git a/test/fixtures/people_search.json b/test/fixtures/people_search.json new file mode 100644 index 000000000..330b73848 --- /dev/null +++ b/test/fixtures/people_search.json @@ -0,0 +1,39 @@ +[{ + "geo_enabled": false, + "profile_sidebar_fill_color": "dddddd", + "description": "Christian husband and father, Ruby developer and web designer. Co-founder of TweetCongress.org.", + "status": { + "in_reply_to_user_id": null, + "in_reply_to_status_id": null, + "truncated": false, + "source": "HootSuite", + "favorited": false, + "in_reply_to_screen_name": null, + "created_at": "Mon Nov 16 21:27:49 +0000 2009", + "id": 5776284007, + "text": "Pointy-haired managers rejoice: PowerPoint and Keynote based mock up tool for iPhone. http://ow.ly/1626Yj" + }, + "following": false, + "verified": false, + "time_zone": "Central Time (US & Canada)", + "profile_sidebar_border_color": "cccccc", + "profile_text_color": "666666", + "followers_count": 2223, + "url": "http://wynnnetherland.com", + "profile_background_image_url": "http://a1.twimg.com/profile_background_images/47314868/twitter.png", + "statuses_count": 2007, + "friends_count": 1647, + "profile_link_color": "35abe9", + "protected": false, + "profile_background_tile": false, + "created_at": "Sat Mar 08 16:34:22 +0000 2008", + "profile_image_url": "http://a1.twimg.com/profile_images/485575482/komikazee_normal.png", + "location": "Dallas, TX", + "name": "Wynn Netherland", + "notifications": false, + "favourites_count": 6, + "profile_background_color": "efefef", + "id": 14100886, + "utc_offset": -21600, + "screen_name": "pengwynn" +}] \ No newline at end of file diff --git a/test/twitter/base_test.rb b/test/twitter/base_test.rb index 6a814ba29..6f7fca884 100644 --- a/test/twitter/base_test.rb +++ b/test/twitter/base_test.rb @@ -95,6 +95,12 @@ class BaseTest < Test::Unit::TestCase stub_get("/friendships/show.json?source_screen_name=dcrec1&target_screen_name=pengwynn", 'friendship.json') @twitter.friendship_show(:source_screen_name => 'dcrec1', :target_screen_name => 'pengwynn').relationship.target.followed_by == false end + + should "be able to search people" do + stub_get("/users/search.json?q=Wynn%20Netherland", 'people_search.json') + people = @twitter.user_search('Wynn Netherland') + people.first.screen_name.should == 'pengwynn' + end end context "when using lists" do