sometastycake / bufflogin

Authorization to buff.163.com through Steam
https://pypi.org/project/bufflogin/
MIT License
23 stars 1 forks source link

How to create sell order? #9

Open Anunah9 opened 1 year ago

Anunah9 commented 1 year ago

I try to create sell order. I log in to the site as in the example. .is_alive_session() specifies true. But when I try to create request, I get the error:

{
  "code": "CSRF Verification Error", 
  "error": "\u0421\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438\u0441\u0442\u0435\u043a, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443", 
  "extra": null
}

Code for creating a request for sale:

async def create_sell_offer(buff: Buff):
    url = 'https://buff.163.com/api/market/sell_order/create/manual_plus'
    params = """{"game": "csgo", "assets": [
        {"game": "csgo", "market_hash_name": "Snakebite Case", "contextid": 2, "assetid": "30175988177",
         "classid": "4418618853", "instanceid": "0", "goods_id": 857515, "price": 10, "income": 9.75,
         "has_market_min_price": False, "cdkey_id": ""}]}"""
    response = await buff.request(url, method='POST', params=params)
    print(response)
sometastycake commented 1 year ago

@Anunah9 Hello You received error 'Срок действия страницы истек, обновите текущую страницу' I think authorization work correctly, but need understand how to work sell orders. You can see in browser dev tools which params send this api. Maybe some additional keys are generated there? I have it in plans

And try to send params as dict, not str

params = {
   "game": "csgo",
   "assets":[
      {
         "game": "csgo",
         "market_hash_name": "Snakebite Case",
         "contextid": 2,
         "assetid": "30175988177",
         "classid": "4418618853",
         "instanceid": "0",
         "goods_id": 857515,
         "price": 10,
         "income": 9.75,
         "has_market_min_price": False,
         "cdkey_id": ""
      }
   ]
}
response = await buff.request(url, method='POST', json=params)
NiJiSann commented 11 months ago

you need to provide lot more information in headers