Exemplo n.º 1
0
Arquivo: bot.py Projeto: zhuki/snapbot
    def _make_request(self, path, data = None, method = 'POST', files = None):
        if data is None:
            data = {}

        headers = {
            'User-Agent': 'Snapchat/8.1.1 (iPhone5,1; iOS 8.1.3; gzip)',
            'Accept-Language': 'en-US;q=1, en;q=0.9',
            'Accept-Locale': 'en'
        }

        now = timestamp()

        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)
        else:
            resp = requests.get(BASE_URL + path, params = data, headers = headers)

        return resp
Exemplo n.º 2
0
    def _make_request(self, path, data=None, method='POST', files=None):
        if data is None:
            data = {}

        headers = {
            'User-Agent': 'Snapchat/8.1.1 (iPhone5,1; iOS 8.1.3; gzip)',
            'Accept-Language': 'en-US;q=1, en;q=0.9',
            'Accept-Locale': 'en'
        }

        now = timestamp()

        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)
        else:
            resp = requests.get(BASE_URL + path, params=data, headers=headers)

        return resp
Exemplo n.º 3
0
 def test_make_request_token(self):
     self.assertEqual(('c6a633f0c2c9e72f7cdf49f888fc64ee7179096c57fdedaad1f'
                       '4ea513dbb7b34'), make_request_token('foo', 'bar'))
Exemplo n.º 4
0
 def test_make_request_token(self):
     self.assertEqual(('c6a633f0c2c9e72f7cdf49f888fc64ee7179096c57fdedaad1f'
                       '4ea513dbb7b34'), make_request_token('foo', 'bar'))