IdoSell API v0.3

 avatar
MrozyHipis
python
2 years ago
1.1 kB
10
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')


# PANEL_LOGIN = os.getenv('USER_LOGIN_GG')
# PANEL_PASS = os.getenv('PANEL_PASS_GG')
# DOMENA = os.getenv('DOMENA_GG')


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 = {'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())
Editor is loading...