fujisakifujita / python-twitter

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

AttributeError: 'unicode' object has no attribute 'get' #144

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
>>> api = twitter.Api(username='user', password='password')
>>> users = api.GetFriends()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "twitter.py", line 1794, in GetFriends
    return [User.NewFromJsonDict(x) for x in data]
  File "twitter.py", line 963, in NewFromJsonDict
    return User(id=data.get('id', None),
AttributeError: 'unicode' object has no attribute 'get'

Password has special characters in it.

uname -a
Linux ubuntu 2.6.32-21-generic-pae #32-Ubuntu SMP Fri Apr 16 09:39:35 UTC 2010 
i686 GNU/Linux

Version Details :
Python 2.6.5
python-twitter-0.6

Original issue reported on code.google.com by hemanth...@gmail.com on 30 Jun 2010 at 8:32

GoogleCodeExporter commented 8 years ago
Get similar error. Password has no special characters - so i get a str eror 
rather than a unicode

Traceback (most recent call last):
  File "twitterCA.py", line 18, in <module>
    users = api.GetFriends()
  File "/home/chris/Desktop/twitter.py", line 1820, in GetFriends
    return [User.NewFromJsonDict(x) for x in data]
  File "/home/chris/Desktop/twitter.py", line 963, in NewFromJsonDict
    return User(id=data.get('id', None),
AttributeError: 'str' object has no attribute 'get'

Original comment by chrisart...@gmail.com on 8 Jul 2010 at 10:03

GoogleCodeExporter commented 8 years ago
I'm getting the same issue with no special characters in the password.

>>> api = twitter.Api(username='username',password='password')
>>> users = api.GetFriends()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home2/spyderfcs/webapps/dev/baselinecreations/ve/src/python-twitter/twitter.py", line 1794, in GetFriends
    return [User.NewFromJsonDict(x) for x in data]
  File "/home2/spyderfcs/webapps/dev/baselinecreations/ve/src/python-twitter/twitter.py", line 963, in NewFromJsonDict
    return User(id=data.get('id', None),
AttributeError: 'unicode' object has no attribute 'get'

Original comment by bradford...@gmail.com on 3 Aug 2010 at 4:00

GoogleCodeExporter commented 8 years ago
The root cause for this turns out to be a Twitter change.  The JSON data 
returned for GetFriends used to only be a list, but now it appears other data 
elements are returned.

I've tweaked how the NewFromJsonDict() method for User works so that it now 
requests the 'users' item from the base JSON returned and then iterating over 
that.

Original comment by bear42 on 24 Aug 2010 at 9:50

GoogleCodeExporter commented 8 years ago
change committed in revision 661a3f9475

Original comment by bear42 on 24 Aug 2010 at 9:57

GoogleCodeExporter commented 8 years ago
I'm getting a simliar error on GetPublicTimeline:

>>>import twitter
>>> ta = twitter.Api(details)
>>> ta.GetPublicTimeline()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-armv6l/egg/twitter.py", line 2301, in GetPublicTimeline
  File "build/bdist.linux-armv6l/egg/twitter.py", line 620, in NewFromJsonDict
AttributeError: 'unicode' object has no attribute 'get'

Original comment by Scubb...@gmail.com on 15 Oct 2012 at 8:24

GoogleCodeExporter commented 8 years ago
got the same:
 statuses = api.GetPublicTimeline()
  File "/usr/local/lib/python2.6/dist-packages/python_twitter-0.8.2-py2.6.egg/twitter.py", line 2301, in GetPublicTimeline
    return [Status.NewFromJsonDict(x) for x in data]
  File "/usr/local/lib/python2.6/dist-packages/python_twitter-0.8.2-py2.6.egg/twitter.py", line 620, in NewFromJsonDict
    return Status(created_at=data.get('created_at', None),
AttributeError: 'unicode' object has no attribute 'get'

Original comment by qmor.q...@googlemail.com on 5 Nov 2012 at 6:00

GoogleCodeExporter commented 8 years ago
Yeah, I got the same with the latest download.  I'm on Ubuntu 12.04.  See below.

I believe the issue is that this endpoint has been renamed to sample.json AND 
is part of the streaming API.  If I change the endpoint in the code and pass in 
base_url to my constructor it moves along, but it is not configured (or cannot 
handle, I don't yet know) to handle streaming.

I would just use a different example and the author should probably just 
deprecate this call or add additional info on how to use it. 

    statuses = api.GetPublicTimeline()
  File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.2-py2.7.egg/twitter.py", line 2301, in GetPublicTimeline
    return [Status.NewFromJsonDict(x) for x in data]
  File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.2-py2.7.egg/twitter.py", line 620, in NewFromJsonDict
    return Status(created_at=data.get('created_at', None),
AttributeError: 'unicode' object has no attribute 'get'

Original comment by tom.mele...@gmail.com on 27 Dec 2012 at 3:36

GoogleCodeExporter commented 8 years ago
GetPublicTimeline() is deprecated in version 1.1 of the Twitter API

your getting this error because that is how Twitter chose to respond to a 
now-deprecated call.

There is no longer any way, except using search, to get what used to be the 
Public Timeline

Original comment by bear42 on 9 Jan 2013 at 5:03

GoogleCodeExporter commented 8 years ago
I am getting this when I run api.GetMentions()

Original comment by mccall...@gmail.com on 3 Feb 2013 at 9:07

GoogleCodeExporter commented 8 years ago
I had code that worked perfectly until yesterday. Now 
tweeter.GetUserTimeline(settings.TWITTER_USER) is throwing this error.

Original comment by ben.welsh@gmail.com on 13 Jun 2013 at 8:14

GoogleCodeExporter commented 8 years ago
I just tested the latest from github with a known good set of credentials and 

api.GetUserTimeline(foo) 

works for me - can you provide more info about what version this is and what 
version of Python

Original comment by bear42 on 13 Jun 2013 at 10:43

GoogleCodeExporter commented 8 years ago
I'm getting this error in python 2.7.2

Original comment by ndep...@alumni.nd.edu on 1 Jul 2013 at 10:05

GoogleCodeExporter commented 8 years ago
Hey Bear

Python v 2.7.5
c:\python27\lib\site-packages\python_twitter-0.8.2-py2.7.egg\twitter.py

I too am getting the following error:

Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\Python\twitter1.py", line 7, in <module>
    statuses = api.GetPublicTimeline()
  File "build\bdist.win-amd64\egg\twitter.py", line 2301, in GetPublicTimeline
    return [Status.NewFromJsonDict(x) for x in data]
  File "build\bdist.win-amd64\egg\twitter.py", line 620, in NewFromJsonDict
    return Status(created_at=data.get('created_at', None),
AttributeError: 'unicode' object has no attribute 'get'

________________________________________________________________________________
____________
My code:

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

statuses = api.GetPublicTimeline()
print [s.user.name for s in statuses]

Original comment by pjsmyth....@gmail.com on 2 Aug 2013 at 1:13

GoogleCodeExporter commented 8 years ago
sorry but getting same eror with GetUserTimeline as well

Original comment by pjsmyth....@gmail.com on 2 Aug 2013 at 1:16