Steam 礼物接口

接口列表:

1.添加购物车

 def add_cart_by_subid(self, subid, sessionid, snr='1_6_4__420', action='add_to_cart'):
        headers = {
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Cache-Control": "max-age=0",
            "Connection": "keep-alive",
            "Content-Type": "application/x-www-form-urlencoded",
            "Host": "store.steampowered.com",
            "Origin": "https://store.steampowered.com",
            "Pragma": "no-cache",
            "Referer": "https://store.steampowered.com/sub/"+subid,
            "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
            "sec-ch-ua-mobile": "?0",
            "Sec-Fetch-Dest": "document",
            "Sec-Fetch-Mode": "navigate",
            "Sec-Fetch-Site": "same-origin",
            "Sec-Fetch-User": "?1",
            "Upgrade-Insecure-Requests": "1",
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
        }

        url = 'https://store.steampowered.com/cart/'
        data = {
            'snr': snr,
            'action': action,
            'subid': subid,
            'originating_snr': '1_direct-navigation__',
            'sessionid': sessionid
         }
        print(data)
        ret = self.web_client.post(url=url, data=data, headers=headers)
        if ret.status_code == 200:
            return  ret.cookies.get('shoppingCartGID')
        return ""

2.确认购物车

 def confirm_cart(self, gidShoppingCart, sessionid, GifteeAccountID, Country, ShippingCountry,
                     PaymentMethod='steamaccount', abortPendingTransactions=0, bHasCardInfo=0, bIsGift=1,
                     GifteeName='nihao', Signature="nihao", Sentiment='祝你好运', GiftMessage='nihao',
                     bSaveBillingAddress=1, bUseRemainingSteamAccount=1, bPreAuthOnly=0,
                     ScheduledSendOnDate=0, gidReplayOfTransID=-1):
        url = 'https://store.steampowered.com/checkout/inittransaction/'
        headers = {
            "Accept": "text/javascript, text/html, application/xml, text/xml, */*",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Cache-Control": "no-cache",
            "Connection": "keep-alive",
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            "Host": "store.steampowered.com",
            "Origin": "https://store.steampowered.com",
            "Pragma": "no-cache",
            "Referer": "https://store.steampowered.com/checkout/?purchasetype=gift&snr=1_8_4__503",
            "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
            "sec-ch-ua-mobile": "?0",
            "Sec-Fetch-Dest": "empty",
            "Sec-Fetch-Mode": "cors",
            "Sec-Fetch-Site": "same-origin",
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
            "X-Prototype-Version": "1.7",
            "X-Requested-With": "XMLHttpRequest"
        }
        data = {
            'gidShoppingCart': str(gidShoppingCart),
            'gidReplayOfTransID': gidReplayOfTransID,
            'PaymentMethod': PaymentMethod,
            'abortPendingTransactions': abortPendingTransactions,
            'bHasCardInfo': bHasCardInfo,
            'CardNumber': '',
            'CardExpirationYear': '',
            'CardExpirationMonth': '',
            'FirstName': '',
            'LastName': '',
             'Address': '',
             'AddressTwo':'',
             'Country': Country,
             'City':'',
              'State':'',
             'PostalCode':'',
              'Phone':'',
              'ShippingFirstName':'',
             'ShippingLastName':'',
             'ShippingAddress':'',
             'ShippingAddressTwo':'',
            'ShippingCountry': ShippingCountry,
            'ShippingCity':'',
            'ShippingState':'',
            'ShippingPostalCode':'',
            'ShippingPhone':'',
             'bIsGift': bIsGift,
            'GifteeAccountID': GifteeAccountID,
             'GifteeEmail':'',
            'GifteeName': GifteeName,
            'GiftMessage': GiftMessage,
            'Sentiment': Sentiment,
             'Signature': Signature,
            'ScheduledSendOnDate': ScheduledSendOnDate,
            'BankAccount':'',
            'BankCode':'',
            'BankIBAN':'',
             'BankBIC':'',
             'TPBankID':'',
            'bSaveBillingAddress': bSaveBillingAddress,
            'gidPaymentID':'',
            'bUseRemainingSteamAccount': bUseRemainingSteamAccount,
            'bPreAuthOnly': bPreAuthOnly,
            'sessionid': sessionid
        }
        ret = self.web_client.post(url=url, data=data, headers=headers)
        if ret.status_code == 200:
            print(ret.text)
            ret = json.loads(ret.text)
            if ret:
                if ret.get("success") == 1:
                    return ret.get('transid')
        return ""

3.确认价格

    def get_final_price(self, transid, shopping_cart_gid):
        headers = {
            "Accept": "text/javascript, text/html, application/xml, text/xml, */*",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Cache-Control": "no-cache",
            "Connection": "keep-alive",
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            "Host": "store.steampowered.com",
            "Origin": "https://store.steampowered.com",
            "Pragma": "no-cache",
            "Referer": "https://store.steampowered.com/checkout/?purchasetype=gift&snr=1_8_4__503",
            "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
            "sec-ch-ua-mobile": "?0",
            "Sec-Fetch-Dest": "empty",
            "Sec-Fetch-Mode": "cors",
            "Sec-Fetch-Site": "same-origin",
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
            "X-Prototype-Version": "1.7",
            "X-Requested-With": "XMLHttpRequest"
        }
        url = 'https://store.steampowered.com/checkout/getfinalprice/'
        params={
                'count': '1',
                'transid': transid,
                'purchasetype': 'gift',
                'microtxnid': '-1',
                'cart': shopping_cart_gid,
                'gidReplayOfTransID': '-1'
            }
        ret = self.web_client.get(url=url, params=params, headers=headers)
        if ret.status_code == 200:
            print(ret.text)
            return True
        return False

4.确认交易

    def confirm_transaction(self, transid, CardCVV2=None,  browserInfo=None):
        url = 'https://store.steampowered.com/checkout/finalizetransaction/'
        headers = {
            "Accept": "text/javascript, text/html, application/xml, text/xml, */*",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Cache-Control": "no-cache",
            "Connection": "keep-alive",
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            "Host": "store.steampowered.com",
            "Origin": "https://store.steampowered.com",
            "Pragma": "no-cache",
            "Referer": "https://store.steampowered.com/checkout/?purchasetype=gift&snr=1_8_4__503",
            "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
            "sec-ch-ua-mobile": "?0",
            "Sec-Fetch-Dest": "empty",
            "Sec-Fetch-Mode": "cors",
            "Sec-Fetch-Site": "same-origin",
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
            "X-Prototype-Version": "1.7",
            "X-Requested-With": "XMLHttpRequest"
        }
        data = {
            'transid': transid,
            'CardCVV2': '',
            'browserInfo': ''#'{"language":"zh-CN", "javaEnabled":"false","colorDepth":24,"screenHeight":1080,"screenWidth":1920}
        }
        print(data)
        ret = self.web_client.post(url=url, data=data, headers=headers)
        if ret.status_code == 200:
            try:
                print(ret.text)
                ret = json.loads(ret.text)
                if ret:
                    if ret.get("success") == 22:
                        return True
            except Exception as e:
                pass
        return False

5.接受礼物

 def accept_gift(self, sessionid, gidGift="2863706723911169653"):
        url = "https://store.steampowered.com/gifts/" + gidGift + "/unpack"
        headers = {
            "Accept": "text/javascript, text/html, application/xml, text/xml, */*",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Cache-Control": "no-cache",
            "Connection": "keep-alive",
            "Content-Type": "application/x-www-form-urlencoded",
            "Host": "store.steampowered.com",
            "Origin": "https://store.steampowered.com",
            "Pragma": "no-cache",
            "Referer": "https://store.steampowered.com/checkout/?purchasetype=gift&snr=1_8_4__503",
            "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
            "sec-ch-ua-mobile": "?0",
            "Sec-Fetch-Dest": "empty",
            "Sec-Fetch-Mode": "cors",
            "Sec-Fetch-Site": "same-origin",
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
            "X-Prototype-Version": "1.7",
            "X-Requested-With": "XMLHttpRequest"
        }
        data = {
            'sessionid': sessionid
        }
        ret = self.web_client.post(url=url, data=data, headers=headers)
        if ret.status_code == 200:
            return True
        return False

5.添加好友

 def add_friend(self, sessionid, self_steam_id, side_steamid):
        url = "https://steamcommunity.com/actions/AddFriendAjax"
        headers = {
            "Accept": "application/json, text/plain, */*",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Cache-Control": "no-cache",
            "Connection": "keep-alive",
            "Host": "steamcommunity.com",
            "Content-Length":"376",
            "Origin":"https://steamcommunity.com",
            "Referer": "https://steamcommunity.com/profiles/"+self_steam_id+"/friends/add",
            #"Content-Type":"multipart/form-data; boundary=----WebKitFormBoundary7BU2HxGU91MWeQ4U",
            "Sec-Fetch-Dest": "empty",
            "Sec-Fetch-Mode": "cors",
            "Sec-Fetch-Site": "same-origin",
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
        }
        data = {
            'sessionID': sessionid,
            'steamid': side_steamid,
            'accept_invite': 0
        }
        print(data)
        #{"invited": ["76561199078240981"], "success": 1}
        ret = self.web_client.post(url=url, data=data, headers=headers)
        print(ret.text)
        if ret.status_code == 200:
            ret = json.loads(ret.text)
            status = ret.get('success')
            if status == 1:
                return True
        return False

6.接受好友

 def accept_friends(self, sessionid, self_steamid, side_steamid):
        url = "https://steamcommunity.com/profiles/"+self_steamid+"/friends/action"
        print(url)
        headers = {
            "Accept": "*/*",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Cache-Control": "no-cache",
            "Connection": "keep-alive",
            "Host": "steamcommunity.com",
            "Origin": "https://steamcommunity.com",
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            "Referer": "https://steamcommunity.com/profiles/"+self_steamid+"/friends/pending",
            "Pragma": "no-cache",
            "Sec-Fetch-Dest": "empty",
            "Sec-Fetch-Mode": "cors",
            "Sec-Fetch-Site": "same-origin",
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
        }
        data = {
            'sessionid': sessionid,
            'steamid': self_steamid,
            'ajax': 1,
            'action': 'accept',
            'steamids[]': side_steamid
        }
        # {"success":1,"rgCounts":{"cFriendsPending":0,"cFriendsBlocked":0,"cFollowing":0,"cGroupsPending":0,"cFriends":1,"cGroups":0,"success":1}}
        print(data)
        ret = self.web_client.post(url=url, data=data, headers=headers)
        if ret.status_code == 200:
            print(ret.text)
            # ret = json.loads(ret.text)
            # status = ret.get('success')
            # if status == 1:
            return True
        return False

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

youyou9526

各位看官,给点下载积分吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值