From 6135e6e3823a37c1d94255ce42cbf3cdf052e467 Mon Sep 17 00:00:00 2001 From: Atif Nazir Date: Sat, 15 Aug 2020 20:57:09 -0700 Subject: [PATCH] add headers to http requests --- README.md | 8 ++++---- block_io/__init__.py | 3 ++- setup.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cbbd65c..1ef3a08 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ This Python package is the official reference client for the Block.io payments API. To use this, you will need the Dogecoin, Bitcoin, or Litecoin API key(s) from Block.io. Go ahead, sign up :) #### ATTENTION: Package name has changed from block_io to block-io for PyPi. -#### COMPATIBILITY: Please use Python2.7+. Also compatible with Python 3.0+. +#### COMPATIBILITY: Please use Python3.0+. Also compatible with Python 2.7. ## Installation [Using virtualenv is recommended when installing Python packages](https://packaging.python.org/en/latest/installing.html#virtual-environments). -Install the package using `pip` for **Python 2.7+**: +Install the package using `pip`: pip install block-io @@ -34,7 +34,7 @@ For more information, see [Python API Docs](https://block.io/api/simple/python). ## Windows Users, Please Note: -You can install it like so on Windows: "pip install block-io==1.1.13" +You can install it like so on Windows: "pip install block-io==1.1.15" Now regarding the vcvarsall.bat error -- that error is due to the fact that pycrypto library is being compiled when you're trying to install the block-io library. @@ -51,7 +51,7 @@ Once this is done, go to C:\Python3.4\Lib\distutils, and create a file calls "di compiler=mingw32 -Now exit your Command Prompt or Python IDE, go to Command Prompt again, type "pip install block-io==1.1.13". +Now exit your Command Prompt or Python IDE, go to Command Prompt again, type "pip install block-io==1.1.15". ## Contributing diff --git a/block_io/__init__.py b/block_io/__init__.py index b04fdd4..8691cfb 100644 --- a/block_io/__init__.py +++ b/block_io/__init__.py @@ -171,6 +171,7 @@ def __init__(self, api_key, pin, version = 2): self.base_url = 'https://block.io/api/v'+str(version)+'/API_CALL/?api_key='+api_key self.withdraw_calls = ['withdraw', 'withdraw_from_address', 'withdraw_from_addresses', 'withdraw_from_label', 'withdraw_from_labels', 'withdraw_from_user_id', 'withdraw_from_users'] self.sweep_calls = ['sweep_from_address'] + self.request_headers = {'Accept': 'application/json', 'User-Agent': 'python:block_io:'+self.clientVersion} def __getattr__(self, attr, *args, **kwargs): @@ -279,7 +280,7 @@ def api_call(self, method, **kwargs): # update the parameters with the API key session = requests.session() - response = session.post(self.base_url.replace('API_CALL',method), data = payload) + response = session.post(self.base_url.replace('API_CALL',method), data = payload, headers = self.request_headers) status_code = response.status_code try: diff --git a/setup.py b/setup.py index 6693f5a..a38eb94 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ long_description = fh.read() setup(name='block-io', - version='1.1.14', + version='1.1.15', description='The easiest way to integrate Bitcoin, Dogecoin and Litecoin in your applications. Sign up at Block.io for your API key.', url='https://github.com/BlockIo/block_io-python', author='Atif Nazir',