Exemple #1
0
        /// <summary>
        /// Creates a new trade offer with a token
        /// </summary>
        /// <param name="message">A message to include with the trade offer</param>
        /// <param name="otherSteamId">The SteamID of the partner we are trading with</param>
        /// <param name="status">The list of items we and they are going to trade</param>
        /// <param name="token">The token of the partner we are trading with</param>
        /// <param name="newTradeOfferId">The trade offer Id that will be created if successful</param>
        /// <returns>True if successfully returns a newTradeOfferId, else false</returns>
        public bool SendTradeOfferWithToken(string message, SteamID otherSteamId, TradeOffer.TradeStatus status,
                                            string token, out string newTradeOfferId)
        {
            if (String.IsNullOrEmpty(token))
            {
                throw new ArgumentNullException("token", "Partner trade offer token is missing");
            }
            var offerToken = new OfferAccessToken()
            {
                TradeOfferAccessToken = token
            };

            var data = new NameValueCollection();

            data.Add("sessionid", SessionId);
            data.Add("partner", otherSteamId.ConvertToUInt64().ToString());
            data.Add("tradeoffermessage", message);
            data.Add("json_tradeoffer", JsonConvert.SerializeObject(status, JsonSerializerSettings));
            data.Add("trade_offer_create_params", JsonConvert.SerializeObject(offerToken, JsonSerializerSettings));

            string referer = string.Format("http://steamcommunity.com/tradeoffer/new/?partner={0}&token={1}",
                                           otherSteamId.AccountID, token);

            return(Request(SendUrl, data, referer, null, out newTradeOfferId));
        }
Exemple #2
0
        /// <summary>
        /// Creates a new trade offer with a token
        /// </summary>
        /// <param name="message">A message to include with the trade offer</param>
        /// <param name="otherSteamId">The SteamID of the partner we are trading with</param>
        /// <param name="status">The list of items we and they are going to trade</param>
        /// <param name="token">The token of the partner we are trading with</param>
        /// <param name="newTradeOfferId">The trade offer Id that will be created if successful</param>
        /// <returns>True if successfully returns a newTradeOfferId, else false</returns>
        public bool SendTradeOfferWithToken(string message, SteamID otherSteamId, TradeOffer.TradeStatus status,
            string token, out string newTradeOfferId)
        {
            if (String.IsNullOrEmpty(token))
            {
                throw new ArgumentNullException("token", "Partner trade offer token is missing");
            }
            var offerToken = new OfferAccessToken() { TradeOfferAccessToken = token };

            var data = new NameValueCollection();
            data.Add("sessionid", steamWeb.SessionId);
            data.Add("serverid", "1");
            data.Add("partner", otherSteamId.ConvertToUInt64().ToString());
            data.Add("tradeoffermessage", message);
            data.Add("json_tradeoffer", JsonConvert.SerializeObject(status, JsonSerializerSettings));
            data.Add("trade_offer_create_params", JsonConvert.SerializeObject(offerToken, JsonSerializerSettings));

            string referer = string.Format("https://steamcommunity.com/tradeoffer/new/?partner={0}&token={1}",
                        otherSteamId.AccountID, token);
            return Request(SendUrl, data, referer, null, out newTradeOfferId);
        }