示例#1
0
        /// <summary>
        /// Modifies an existing trade offer.
        /// </summary>
        /// <param name="partnerSid">The SteamId64 (ulong) of the person whose offer will be modified.</param>
        /// <param name="tradeoffermessage">An otpional message to be sent with the trade offer. Can be null.</param>
        /// <param name="serverid">Almost always 1, not quite sure what other numbers do.</param>
        /// <param name="tradeofferidCountered">The TradeId of the offer to counter or modify.</param>
        /// <param name="offer">A TradeOffer object containing the trade parameters. </param>
        /// <param name="container">Auth Cookies MUST be passed here, the function will fail if not.</param>
        /// <returns>A SendOfferResponse object.</returns>
        public SendOfferResponse ModifyTradeOffer(ulong partnerSid, string tradeoffermessage,
                                                  string serverid, uint tradeofferidCountered, TradeOffer offer, CookieContainer container)
        {
            const string url = "https://steamcommunity.com/tradeoffer/new/send";

            container.Add(new Cookie("bCompletedTradeOfferTutorial", "true")
            {
                Domain = "steamcommunity.com"
            });
            string sessionid = (from Cookie cookie in container.GetCookies(new Uri("https://steamcommunity.com"))
                                where cookie.Name == "sessionid"
                                select cookie.Value).FirstOrDefault();

            var data = new Dictionary <string, string>
            {
                { "sessionid", sessionid },
                { "serverid", serverid },
                { "partner", partnerSid.ToString() },
                { "tradeoffermessage", tradeoffermessage },
                { "json_tradeoffer", JsonConvert.SerializeObject(offer) },
                { "captcha", string.Empty },
                { "trade_offer_create_params", "{}" },
                { "tradeofferid_countered", tradeofferidCountered.ToString() }
            };

            return(_web.Fetch(url, "POST", data, container, false,
                              "https://steamcommunity.com/tradeoffer/" + tradeofferidCountered + "/")
                   .DeserializeJson <SendOfferResponse>());
        }