购买有限物品的 Python Roblox 问题 [英] Python Roblox issue with buying limited items
问题描述
所以在 roblox 中,我试图向他们的 api 发送请求以购买物品.代码如下:
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
当我尝试在 5 robux 衬衫上运行 buyItem 功能时,它毫无问题地购买了它.但是后来我尝试购买限量版,但它不会购买.是的,有足够的 robux.帮助表示赞赏!谢谢!
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!
推荐答案
我在 github 上找过,发现了类似的东西.我想它会帮助你.抱歉回复太长.我认为可能需要其他参数,请参阅第 370 行.
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
这篇关于购买有限物品的 Python Roblox 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!