amanshine / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

TwitterError: json decoding when using api.GetUser() #222

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is my first time posting an issue online for open source projects - hope 
I'm doing it right!

What steps will reproduce the problem?
This code:

results = api.GetSearch(search_string, None, None, 20)
for result in results:
    tweeting_user = api.GetUser(result) #Error occurs here
    print tweeting_user.name + "("+ tweeting_user.id +"):"
    print result.text
    nextresult = raw_input()

What is the expected output? What do you see instead?
Should return a user type, but errors out.

What version of the product are you using? On what operating system?
Python 2.7 on Fedora 13 (32-bit)

Please provide any additional information below.
Error output:
  File "/usr/lib/python2.7/site-packages/python_twitter-0.8.2-py2.7.egg/twitter.py", line 3064, in GetUser
    data = self._ParseAndCheckTwitter(json)
  File "/usr/lib/python2.7/site-packages/python_twitter-0.8.2-py2.7.egg/twitter.py", line 3674, in _ParseAndCheckTwitter
    raise TwitterError("json decoding")
twitter.TwitterError: json decoding

Original issue reported on code.google.com by sirus.saeedipour on 11 Jan 2012 at 5:24

GoogleCodeExporter commented 8 years ago
this works fine to me.

Make sure you passed the user id to the api call: api.GetUserTimeline(u.id)

api = twitter.Api(consumer_key=consumer_key, consumer_secret=consumer_secret,
                  access_token_key=access_token, access_token_secret=access_token_secret)

users = api.GetFriends()

# Fetch each friends timeline:

for u in users:

    print u

    try:
        statuses = api.GetUserTimeline(u.id)
        print [s.text for s in statuses]
    except TwitterError, t:
        print t

cheers 

Uolter

Original comment by wtraspad on 28 Jan 2012 at 9:28