From c61ce91ae180fd8b07938cf17e0c5232c7d0db98 Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 5 Mar 2015 14:44:13 +0100 Subject: [PATCH 1/4] Update bot.py Add proxies setting for the API request --- snapchat_bots/bot.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/snapchat_bots/bot.py b/snapchat_bots/bot.py index b7214dd..e580dda 100755 --- a/snapchat_bots/bot.py +++ b/snapchat_bots/bot.py @@ -164,6 +164,11 @@ def _make_request(self, path, data = None, method = 'POST', files = None): if data is None: data = {} + proxies = { + "http": HTTP_PROXIE, + "https": HTTPS_PROXIE + } + headers = { 'User-Agent': 'Snapchat/8.1.1 (iPhone5,1; iOS 8.1.3; gzip)', 'Accept-Language': 'en-US;q=1, en;q=0.9', @@ -175,7 +180,10 @@ def _make_request(self, path, data = None, method = 'POST', files = None): if method == 'POST': data['timestamp'] = now data['req_token'] = make_request_token(self.auth_token, str(now)) - resp = requests.post(BASE_URL + path, data = data, files = files, headers = headers) + if proxies: + resp = requests.post(BASE_URL + path, data = data, files = files, headers = headers, proxies = proxies) + else: + resp = requests.post(BASE_URL + path, data = data, files = files, headers = headers) else: resp = requests.get(BASE_URL + path, params = data, headers = headers) From 3d938c6d639f1409c1138ee2cebcb031f4edde95 Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 5 Mar 2015 14:49:13 +0100 Subject: [PATCH 2/4] Update bot.py --- snapchat_bots/bot.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/snapchat_bots/bot.py b/snapchat_bots/bot.py index e580dda..e5815be 100755 --- a/snapchat_bots/bot.py +++ b/snapchat_bots/bot.py @@ -180,10 +180,9 @@ def _make_request(self, path, data = None, method = 'POST', files = None): if method == 'POST': data['timestamp'] = now data['req_token'] = make_request_token(self.auth_token, str(now)) - if proxies: - resp = requests.post(BASE_URL + path, data = data, files = files, headers = headers, proxies = proxies) - else: - resp = requests.post(BASE_URL + path, data = data, files = files, headers = headers) + + resp = requests.post(BASE_URL + path, data = data, files = files, headers = headers, proxies = proxies) + else: resp = requests.get(BASE_URL + path, params = data, headers = headers) From 155b6e30f8dc07c63d2b26d2abf36bddbd5b1c2d Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 5 Mar 2015 14:49:40 +0100 Subject: [PATCH 3/4] Update bot.py --- snapchat_bots/bot.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snapchat_bots/bot.py b/snapchat_bots/bot.py index e5815be..1d0c5ac 100755 --- a/snapchat_bots/bot.py +++ b/snapchat_bots/bot.py @@ -180,10 +180,8 @@ def _make_request(self, path, data = None, method = 'POST', files = None): if method == 'POST': data['timestamp'] = now data['req_token'] = make_request_token(self.auth_token, str(now)) - resp = requests.post(BASE_URL + path, data = data, files = files, headers = headers, proxies = proxies) - else: - resp = requests.get(BASE_URL + path, params = data, headers = headers) + resp = requests.get(BASE_URL + path, params = data, headers = headers, proxies = proxies) return resp From d946d1956420d9eea9102b212f7e92ff7e17bb8b Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 5 Mar 2015 15:20:01 +0100 Subject: [PATCH 4/4] Update bot.py --- snapchat_bots/bot.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snapchat_bots/bot.py b/snapchat_bots/bot.py index 1d0c5ac..6b16d2f 100755 --- a/snapchat_bots/bot.py +++ b/snapchat_bots/bot.py @@ -165,8 +165,7 @@ def _make_request(self, path, data = None, method = 'POST', files = None): data = {} proxies = { - "http": HTTP_PROXIE, - "https": HTTPS_PROXIE + "http": HTTP_PROXIE } headers = {