Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support for user search

  • Loading branch information...
commit 54e046924431a08e3dfce06f571f71ebb76f7bbd 1 parent 8ceedfb
Wynn Netherland authored
2  History
View
@@ -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
6 lib/twitter/base.rb
View
@@ -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={})
39 test/fixtures/people_search.json
View
@@ -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 test/twitter/base_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.