Skip to content

Commit 150d831

Browse files
committed
Updated GetFollowerIDs to use the same interface as GetFriendIDs
1 parent a3bdd9e commit 150d831

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

twitter.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,22 +3063,31 @@ def GetFriendIDs(self, user=None, cursor=-1):
30633063
data = self._ParseAndCheckTwitter(json)
30643064
return data
30653065

3066-
def GetFollowerIDs(self, userid=None, cursor=-1):
3067-
'''Fetch the sequence of twitter.User instances, one for each follower
3066+
def GetFollowerIDs(self, user=None, cursor=-1):
3067+
'''Returns a list of twitter user id's for every person
3068+
that is following the specified user.
30683069
3069-
The twitter.Api instance must be authenticated.
3070+
Args:
3071+
user:
3072+
The id or screen_name of the user to retrieve the id list for
3073+
[Optional]
30703074
3071-
Returns:
3072-
A sequence of twitter.User instances, one for each follower
3073-
'''
3074-
url = '%s/followers/ids.json' % self.base_url
3075-
parameters = {}
3076-
parameters['cursor'] = cursor
3077-
if userid:
3078-
parameters['user_id'] = userid
3079-
json = self._FetchUrl(url, parameters=parameters)
3080-
data = self._ParseAndCheckTwitter(json)
3081-
return data
3075+
Returns:
3076+
A list of integers, one for each user id.
3077+
'''
3078+
3079+
if not user and not self._oauth_consumer:
3080+
raise TwitterError("twitter.Api instance must be authenticated")
3081+
if user:
3082+
url = '%s/followers/ids/%s.json' % (self.base_url, user)
3083+
else:
3084+
url = '%s/followers/ids.json' % self.base_url
3085+
3086+
parameters = {}
3087+
parameters['cursor'] = cursor
3088+
json = self._FetchUrl(url, parameters=parameters)
3089+
data = self._ParseAndCheckTwitter(json)
3090+
return data
30823091

30833092
def GetFollowers(self, user=None, cursor=-1):
30843093
'''Fetch the sequence of twitter.User instances, one for each follower

0 commit comments

Comments
 (0)