Python Roblox issue with buying limited items

北慕城南 提交于 2020-06-17 13:13:32

问题


So in roblox, I am trying to send a request to thier api to buy an item. Here is the code:

def buyItem(self,itemid, cookie, price=None):
        info = self.getItemInfo(itemid)
        url="https://economy.roblox.com/v1/purchases/products/{}".format(info["ProductId"])
        print(url)
        cookies = {
            '.ROBLOSECURITY': cookie
        }
        headers = {
            'X-CSRF-TOKEN': self.setXsrfToken(cookie)
        }
        data={
            'expectedCurrency': 1, 'expectedPrice': info["PriceInRobux"] if price == None else price, 'expectedSellerId': info["Creator"]["Id"]
            }
        r = self.s.post(url, data=data, cookies=cookies, headers=headers)
        return r
def getItemInfo(self,itemid):
        return self.s.get("https://api.roblox.com/marketplace/productinfo?assetId="+str(itemid)).json()
def setXsrfToken(self, cookie):
        cookies = {
            '.ROBLOSECURITY': cookie
        }
        r = self.s.get("https://roblox.com/home", cookies=cookies)
        tok = r.text[r.text.find("Roblox.XsrfToken.setToken('") + 27::]
        tok = tok[:tok.find("');"):]
        return tok

When I tried to run the buyItem function on a 5 robux shirt, it bought it with no problem. But then I tried to buy a limited and it wouldn't buy it. Also yes, there was enough robux. Help is appreciated! Thanks!


回答1:


I looked for it on github and found something similar. I think it will help you. Sorry for the long reply. I think additional parameters may be needed, see line 370.

post("https://web.roblox.com/api/item.ashx?rqtype=purchase&productID={}
    &expectedCurrency=1
    &expectedPrice={}
    &expectedSellerID={}
    &userAssetID={}".format(
      self.getItemInfo(
         aid['ProductId'],
         seller['Price'],
         seller['SellerId'],
         seller['UserAssetId']),
    headers = {"X-CSRF-TOKEN":self.token})

https://github.com/judge2020/LimitedSniper/blob/master/roblopy.py



来源:https://stackoverflow.com/questions/60686834/python-roblox-issue-with-buying-limited-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!