Skip to content

Commit

Permalink
Support for user search
Browse files Browse the repository at this point in the history
  • Loading branch information
Wynn Netherland committed Nov 17, 2009
1 parent 8ceedfb commit 54e0469
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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
Expand Down
6 changes: 6 additions & 0 deletions lib/twitter/base.rb
Expand Up @@ -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={})
Expand Down
39 changes: 39 additions & 0 deletions 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": "<a href=\"http://www.hootsuite.com\" rel=\"nofollow\">HootSuite</a>",
"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"
}]
6 changes: 6 additions & 0 deletions test/twitter/base_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 54e0469

Please sign in to comment.