Reputation: 1061
I am refering to this article.The article used twython
to download user profile information with reference to UserID
(int) and I am trying to use username
(str).
The exact same code works when userID
is given and when the same user's username
is given this gives me an error.
what should I change in the program to read and process the usernames ? I have checked several question here and other forums the 404
is shown when the user is no longer available twitter user.
But to test that theory I did use same userid and username of which I can return the user profile fields but when the same user's username or screenname is used I am getting error.
Error:
Traceback (most recent call last):
File "user_prof_twython.py", line 25, in <module>
users = t.lookup_user(user_id = ids)
File "/usr/local/lib/python2.7/dist-packages/twython/endpoints.py", line 522, in lookup_user
return self.get('users/lookup', params=params)
File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 264, in get
return self.request(endpoint, params=params, version=version)
File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 258, in request
api_call=url)
File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 194, in _request
retry_after=response.headers.get('X-Rate-Limit-Reset'))
twython.exceptions.TwythonError: Twitter API returned a 404 (Not Found), No user matches for specified terms.
Upvotes: 1
Views: 672
Reputation: 744
This works for me. Is this what you want?
Please note, screen_name can be a list. e.g.: ["aaaa","bbb","ccc","ddd"]
# Create a Twython instance with your application key and access token
twitter = Twython(APP_KEY, APP_SECRET, oauth_version=1)
output = twitter.lookup_user(screen_name="BarackObama")
for user in output:
print user["id_str"]
print user['created_at']
print user['followers_count']
Upvotes: 1