Update Location

2 views
Skip to first unread message

Laundryman

unread,
Nov 6, 2009, 12:24:48 PM11/6/09
to python-twitter
I wrote this extension if you need to update location in the user
profile
def UpdateProfileLocation(self, Location):
'''Update user profile location from the authenticated user.

The twitter.Api instance must be authenticated.

Args:
location:
Location info. Must be less than or equal to
30 characters.
Returns:
A twitter.User instance representing the authenticated user.
'''
if not self._username:
raise TwitterError("The twitter.Api instance must be
authenticated.")

url = 'http://twitter.com/account/update_profile.json'

if len(Location) > 30:
raise TwitterError("Text must be less than or equal to %d
characters. "
"Consider using PostUpdates." % 30)

data = {'location': Location}

json = self._FetchUrl(url, post_data=data)
data = simplejson.loads(json)
self._CheckForTwitterError(data)
return User.NewFromJsonDict(data)
Reply all
Reply to author
Forward
0 new messages