Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def CreateFriendship(self, user):
'''Befriends the user specified in the user parameter as the authenticating user.
The twitterapi.Api instance must be authenticated.
Args:
The ID or screen name of the user to befriend.
Returns:
A twitterapi.User instance representing the befriended user.
'''
url = 'http://twitter.com/friendships/create/%s.json' % user
json = self._FetchUrl(url, post_data={})
data = simplejson.loads(json)
return User.NewFromJsonDict(data)
def GetUser(self, user):
'''Returns a single user.
The twitterapi.Api instance must be authenticated.
Args:
user: The username or id of the user to retrieve.
Returns:
A twitterapi.User instance representing that user
'''
url = 'http://twitter.com/users/show/%s.json' % user
json = self._FetchUrl(url)
data = simplejson.loads(json)
return User.NewFromJsonDict(data)
not specified, defaults to the authenticated user. [optional]
The twitterapi.Api instance must be authenticated.
Returns:
A sequence of twitterapi.User instances, one for each friend
'''
if not self._username:
raise TwitterError("twitterapi.Api instance must be authenticated")
if user:
url = 'http://twitter.com/statuses/friends/%s.json' % user
else:
url = 'http://twitter.com/statuses/friends.json'
json = self._FetchUrl(url)
data = simplejson.loads(json)
return [User.NewFromJsonDict(x) for x in data]
def DestroyFriendship(self, user):
'''Discontinues friendship with the user specified in the user parameter.
The twitterapi.Api instance must be authenticated.
Args:
The ID or screen name of the user with whom to discontinue friendship.
Returns:
A twitterapi.User instance representing the discontinued friend.
'''
url = 'http://twitter.com/friendships/destroy/%s.json' % user
json = self._FetchUrl(url, post_data={})
data = simplejson.loads(json)
return User.NewFromJsonDict(data)
def GetFeatured(self):
'''Fetch the sequence of twitterapi.User instances featured on twitter.com
The twitterapi.Api instance must be authenticated.
Returns:
A sequence of twitterapi.User instances
'''
url = 'http://twitter.com/statuses/featured.json'
json = self._FetchUrl(url)
data = simplejson.loads(json)
return [User.NewFromJsonDict(x) for x in data]
def GetFollowers(self):
'''Fetch the sequence of twitterapi.User instances, one for each follower
The twitterapi.Api instance must be authenticated.
Returns:
A sequence of twitterapi.User instances, one for each follower
'''
if not self._username:
raise TwitterError("twitterapi.Api instance must be authenticated")
url = 'http://twitter.com/statuses/followers.json'
json = self._FetchUrl(url)
data = simplejson.loads(json)
return [User.NewFromJsonDict(x) for x in data]