IdoSell API +header
MrozyHipis
python
3 years ago
1.3 kB
11
Indexable
import requests
from dotenv import load_dotenv
import os.path
from datetime import datetime
from datetime import timedelta
import time
import hashlib
import json
load_dotenv()
PANEL_LOGIN = os.getenv('PANEL_LOGIN_MS')
PANEL_PASS = os.getenv('PANEL_PASS_MS')
DOMENA = os.getenv('DOMENA_MS')
def HashPassword(passw):
hash = hashlib.sha1(passw.encode("utf-8"))
return hash.hexdigest()
def GenerateKey(hashedPassword):
date = datetime.now().strftime("%Y%m%d")
strToHash = date + hashedPassword
hash = hashlib.sha1(strToHash.encode("utf-8"))
return hash.hexdigest()
HTTPS_STOCK = "http://" + DOMENA + ".iai-shop.com/api/?gate=productsstocks/get/180/json"
req = {'headers': {}}
req['headers']['Accept'] = "application/json"
req['headers']['Content-Type'] = "application/json;charset=UTF-8"
req = {'authenticate': {}}
req['authenticate']['system_key'] = GenerateKey(HashPassword(PANEL_PASS))
req['authenticate']['system_login'] = PANEL_LOGIN
json_req = json.dumps(req)
html_response = requests.post(HTTPS_STOCK, json=json_req)
print(html_response.json())
# respone - {'authenticate': {'system_login': '', 'system_key': ''}, 'errors': {'faultCode': 2, 'faultString': 'Błędne hasło oraz login'}}
Editor is loading...