forked from ideoforms/python-twitter-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwitter-oauth-user-search.py
More file actions
executable file
·26 lines (20 loc) · 990 Bytes
/
twitter-oauth-user-search.py
File metadata and controls
executable file
·26 lines (20 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python
#-----------------------------------------------------------------------
# twitter-oauth-user-search
# - performs a search for users matching a certain query
#-----------------------------------------------------------------------
from twitter import *
# these tokens are necessary for user authentication
consumer_key = "XxXxXxxXXXxxxxXXXxXX"
consumer_secret = "xXXXXXXXXxxxxXxXXxxXxxXXxXxXxxxxXxXXxxxXXx"
access_key = "XXXXXXXX-xxXXxXXxxXxxxXxXXxXxXxXxxxXxxxxXxXXxXxxXX"
access_secret = "XxXXXXXXXXxxxXXXxXXxXxXxxXXXXXxXxxXXXXx"
# create twitter API object
auth = OAuth(access_key, access_secret, consumer_key, consumer_secret)
twitter = Twitter(auth = auth)
# perform a user search
# twitter API docs: https://dev.twitter.com/docs/api/1/get/users/search
results = twitter.users.search(q = '"New Cross"')
# loop through each of the users, and print their details
for user in results:
print "@%s (%s): %s" % (user["screen_name"], user["name"], user["location"])