Skip to content

Commit 607cc7b

Browse files
committed
added DestroyListsMember()
1 parent 156dd0a commit 607cc7b

1 file changed

Lines changed: 68 additions & 4 deletions

File tree

twitter.py

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4342,10 +4342,10 @@ def CreateSubscription(self,
43424342
return User.NewFromJsonDict(data)
43434343

43444344
def DestroySubscription(self,
4345-
owner_screen_name=False,
4346-
owner_id=False,
4347-
list_id=None,
4348-
slug=None):
4345+
owner_screen_name=False,
4346+
owner_id=False,
4347+
list_id=None,
4348+
slug=None):
43494349
'''Destroys the subscription to a list for the authenticated user
43504350
43514351
The twitter.Api instance must be authenticated.
@@ -4827,6 +4827,70 @@ def CreateListsMember(self,
48274827
data = self._ParseAndCheckTwitter(json.content)
48284828
return List.NewFromJsonDict(data)
48294829

4830+
def DestroyListsMember(self,
4831+
list_id=None,
4832+
slug=None,
4833+
owner_screen_name=False,
4834+
owner_id=False,
4835+
user_id=None,
4836+
screen_name=None):
4837+
'''Destroys the subscription to a list for the authenticated user
4838+
4839+
The twitter.Api instance must be authenticated.
4840+
4841+
Twitter endpoint: /lists/subscribers/destroy
4842+
4843+
Args:
4844+
list_id:
4845+
The numerical id of the list.
4846+
slug:
4847+
You can identify a list by its slug instead of its numerical id. If you
4848+
decide to do so, note that you'll also have to specify the list owner
4849+
using the owner_id or owner_screen_name parameters.
4850+
owner_screen_name:
4851+
The screen_name of the user who owns the list being requested by a slug.
4852+
owner_id:
4853+
The user ID of the user who owns the list being requested by a slug.
4854+
user_id:
4855+
User_id or a list of User_id's to add to the list. If not given, then screen_name is required.
4856+
screen_name:
4857+
Screen_name or a list of Screen_name's to add to the list. If not given, then user_id is required.
4858+
Returns:
4859+
A twitter.List instance representing the removed list.
4860+
'''
4861+
url = '%s/lists/members/destroy.json' % (self.base_url)
4862+
if not self.__auth:
4863+
raise TwitterError("The twitter.Api instance must be authenticated.")
4864+
data = {}
4865+
if list_id:
4866+
try:
4867+
data['list_id'] = long(list_id)
4868+
except ValueError:
4869+
raise TwitterError("list_id must be an integer")
4870+
elif slug:
4871+
data['slug'] = slug
4872+
if owner_id:
4873+
try:
4874+
data['owner_id'] = long(owner_id)
4875+
except ValueError:
4876+
raise TwitterError("owner_id must be an integer")
4877+
elif owner_screen_name:
4878+
data['owner_screen_name'] = owner_screen_name
4879+
else:
4880+
raise TwitterError("Identify list by list_id or owner_screen_name/owner_id and slug")
4881+
else:
4882+
raise TwitterError("Identify list by list_id or owner_screen_name/owner_id and slug")
4883+
if user_id:
4884+
try:
4885+
data['user_id'] = long(user_id)
4886+
except ValueError:
4887+
raise TwitterError("user_id must be an integer")
4888+
elif screen_name:
4889+
data['screen_name'] = screen_name
4890+
json = self._RequestUrl(url, 'POST', data=data)
4891+
data = self._ParseAndCheckTwitter(json.content)
4892+
return List.NewFromJsonDict(data)
4893+
48304894
def GetLists(self, user_id=None, screen_name=None, count=None, cursor=-1):
48314895
'''Fetch the sequence of lists for a user.
48324896

0 commit comments

Comments
 (0)