Open GoogleCodeExporter opened 9 years ago
Update: better handling of missing geo data:
if (data.get('geo', None) != None):
if (data['geo'].get('coordinates', None) != None):
if (len(data['geo']['coordinates']) == 2):
status_location_string = "%s, %s" % (data['geo']['coordinates'][0],
data['geo']['coordinates'][1])
Original comment by andrewse...@gmail.com
on 30 Nov 2009 at 4:28
Update 2: fallback to status location string:
@staticmethod
def NewFromJsonDict(data):
'''Create a new instance based on a JSON dict.
Args:
data: A JSON dict, as converted from the JSON in the twitter API
Returns:
A twitter.Status instance
'''
if 'user' in data:
user = User.NewFromJsonDict(data['user'])
else:
user = None
location_string = data.get('location', None)
# get the /geo/coordinates/ data, parse to location string
if (data.get('geo', None) != None):
if (data['geo'].get('coordinates', None) != None):
if (len(data['geo']['coordinates']) == 2):
location_string = "%s, %s" % (data['geo']['coordinates'][0],
data['geo']['coordinates'][1])
return Status(created_at=data.get('created_at', None),
favorited=data.get('favorited', None),
id=data.get('id', None),
text=data.get('text', None),
location=location_string,
in_reply_to_screen_name=data.get('in_reply_to_screen_name', None),
in_reply_to_user_id=data.get('in_reply_to_user_id', None),
in_reply_to_status_id=data.get('in_reply_to_status_id', None),
truncated=data.get('truncated', None),
source=data.get('source', None),
user=user)
Original comment by andrewse...@gmail.com
on 30 Nov 2009 at 12:17
In theory, yes, python-twitter will definitely support geo.
Right now I'm holding off on any new development until a few licensing
questions are
addressed, but hopefully this is mostly just a formality:
https://groups.google.com/group/twitter-development-
talk/browse_thread/thread/9f90046f6469fb7b/64add3e7a298b395
In the meantime, you may want to clone the project and make the changes you
listed
above:
http://code.google.com/p/python-twitter/source/checkout
Once the licensing is dealt with we can merge the new code back in from the
clone.
And if you do make a clone to support geo, please feel free to mention it here,
so
others interested can pull from it even before it hits the main development
branch.
Thanks!
Original comment by dclinton
on 2 Dec 2009 at 2:48
I created a clone to try to apply these changes, but I couldn't get it to work
yet...
Original comment by nwerneck@gmail.com
on 12 Dec 2009 at 5:23
Clone created here:
https://code.google.com/r/andrewseigner-python-twitter/source/browse/twitter.py
diff summary:
added geo, trends, and rate limit support
detailed changes:
added Status::GetLocation()
added Status::SetLocation()
added geo support to Status::NewFromJsonDict()
added Api::GetTrendsCurrent()
added Api::GetRateLimitStatus()
added Api::MaximumHitFrequency()
Original comment by andrewse...@gmail.com
on 13 Dec 2009 at 1:27
Original issue reported on code.google.com by
andrewse...@gmail.com
on 30 Nov 2009 at 3:37