I am trying to run script in Debian.
In python2 and python3 I get error "No module named 'httplib'"
$sudo pip install httplib2
and
$sudo pip3 install httplib2
did not help.
import httplib
import urllib
import json
import hashlib
import hmac
from collections import OrderedDict
server = "api.---.net"
api_key = "---"
secret_key = "---"
def get(url):
conn = httplib.HTTPSConnection(server)
conn.request("GET", url)
response = conn.getresponse()
data = json.load(response)
conn.close()
return data
def post(url, params):
conn = httplib.HTTPSConnection(server)
data = OrderedDict(sorted(params))
encoded_data = urllib.urlencode(data)
sign = hmac.new(secret_key, msg=encoded_data, digestmod=hashlib.sha256).hexdigest().upper()
headers = {"Api-key": api_key, "Sign": sign, "Content-type": "application/x-www-form-urlencoded"}
conn.request("POST", url, encoded_data, headers)
response = conn.getresponse()
data = json.load(response)
conn.close()
return data