From fe3fcbdb04e2096cc2b4146383ad8f55dfd437c2 Mon Sep 17 00:00:00 2001 From: Ajay Nadathur Date: Sun, 30 Dec 2012 23:06:36 +0000 Subject: [PATCH] moved api version into __init__ method and added method to delete multiple users from a list in batch mode --- twython/twitter_endpoints.py | 4 ++++ twython/twython.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/twython/twitter_endpoints.py b/twython/twitter_endpoints.py index be0c718..ca9a34f 100644 --- a/twython/twitter_endpoints.py +++ b/twython/twitter_endpoints.py @@ -309,6 +309,10 @@ api_table = { 'url': '/lists/members/destroy.json', 'method': 'POST', }, + 'deleteListMembers': { + 'url': '/lists/members/destroy_all.json', + 'method': 'POST' + }, 'getListSubscribers': { 'url': '/lists/subscribers.json', 'method': 'GET', diff --git a/twython/twython.py b/twython/twython.py index 0a57d92..816ed81 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -82,7 +82,7 @@ class TwythonRateLimitError(TwythonError): class Twython(object): def __init__(self, app_key=None, app_secret=None, oauth_token=None, oauth_token_secret=None, \ - headers=None, callback_url=None, twitter_token=None, twitter_secret=None, proxies=None): + headers=None, callback_url=None, twitter_token=None, twitter_secret=None, proxies=None, version='1'): """Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below). :param app_key: (optional) Your applications key @@ -95,6 +95,7 @@ class Twython(object): """ # Needed for hitting that there API. + self.api_version = version self.api_url = 'https://api.twitter.com/%s' self.request_token_url = self.api_url % 'oauth/request_token' self.access_token_url = self.api_url % 'oauth/access_token' @@ -145,8 +146,7 @@ class Twython(object): fn = api_table[api_call] url = re.sub( '\{\{(?P[a-zA-Z_]+)\}\}', - # The '1' here catches the API version. Slightly hilarious. - lambda m: "%s" % kwargs.get(m.group(1), '1'), + lambda m: "%s" % kwargs.get(m.group(1), self.api_version), base_url + fn['url'] )