/// <summary>
        /// Gets the asset class info of an item, must provide ClassID/InstanceID in IDs
        /// </summary>
        /// <param name="apiKey">Your Steam API key</param>
        /// <param name="appid">Uint32 number that represents the game to retrieve item data from.</param>
        /// <param name="Ids">Dictionary MUST contain ClassID/InstanceID of item.</param>
        /// <returns></returns>
        public AssetClassInfo GetAssetClassInfo(uint appid, Dictionary <string, string> ids)
        {
            const string url  = BaseUrl + "GetAssetClassInfo/v0001/";
            var          data = new Dictionary <string, string>
            {
                { "key", _apiKey },
                { "appid", appid.ToString() },
                { "class_count", ids.Count.ToString() }
            };
            int currentClass = 0;

            foreach (var key in ids) //make only request per appid at a time
            {
                data.Add("classid" + currentClass, key.Key);
                data.Add("instanceid" + currentClass, key.Value);
                currentClass++;
            }

            dynamic dynamicinfo = JsonConvert.DeserializeObject <dynamic>(_web.Fetch(url, "GET", data, null, false).ReadStream()).result;

            Dictionary <string, dynamic> desrDictionary =
                JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(dynamicinfo.ToString());

            desrDictionary.Remove("success");

            return(JsonConvert.DeserializeObject <AssetClassInfo>(desrDictionary.Values.First().ToString()));
        }
Beispiel #2
0
        /// <summary>
        /// Sets the container to contain a MarketEligibility cookie. Required before trading.
        /// </summary>
        /// <param name="steamId">The SteamId of the bot.</param>
        /// <param name="container">The bot CookieContainer</param>
        public void EligibilityCheck(ulong steamId, CookieContainer container)
        {
            const string url  = BaseUrl + "eligibilitycheck/";
            var          data = new Dictionary <string, string> {
                { "goto", "/profiles/" + steamId + "/tradeoffers/" }
            };

            _web.Fetch(url, "GET", data, container, false);
        }
Beispiel #3
0
        /// <summary>
        /// Requests all trade offers.
        /// </summary>
        /// <param name="data">A dictionary containing the URL params found here: https://developer.valvesoftware.com/wiki/Steam_Web_API/IEconService at GetTradeOffers (v1).
        /// ex: [leftarrow]"get_sent_offers","1"[rightarrow]. Please note, [leftarrow] and [rightarrow] correspond to the keys on the keyboard.</param>
        /// <returns></returns>
        public TradeOffersList GetTradeOffers(Dictionary <string, string> data)
        {
            const string url = BaseUrl + "GetTradeOffers/v1/";

            data.Add("key", _apiKey);
            data.Add("format", "json");
            return
                (JsonConvert.DeserializeObject <TradeOffers>(
                     WebUtility.UrlDecode(_web.Fetch(url, "GET", data).ReadStream())).Response);
        }
Beispiel #4
0
        /// <summary>
        /// Retrieves the friends list of the specified steamid64.
        /// The profile must be set to public or the owner of the api key must be friends with them.
        /// The profile cannot be private or the method will fail and it will return null.
        /// </summary>
        /// <param name="steamId">SteamId64 to retrieve the friends list from.</param>
        /// <param name="relationship">All/Friend, there are others but I do not know what.</param>
        /// <returns>Null upon failure, otherwise a list of Friend objects.</returns>
        public List <Friend> GetFriendList(ulong steamId, string relationship = "")
        {
            const string url  = BaseUrl + "GetFriendList/v1/";
            var          data = new Dictionary <string, string>
            {
                { "key", _apiKey },
                { "steamid", steamId.ToString() },
                { "relationship", relationship }
            };

            return(_web.Fetch(url, "GET", data, null, false).DeserializeJson <GetFriendListResult>().Friendslist.Friends);
        }
Beispiel #5
0
        /// <summary>
        /// Logs on to Steam community chat.
        /// </summary>
        /// <returns>WebPresenceOAuthLogonResponse</returns>
        private WebPresenceOAuthLogonResponse Logon()
        {
            const string url    = BaseAuthUrl + "Logon/v0001/";
            string       jQuery = string.Format(_basejQuery, UnixTimeNow());
            var          data   = new Dictionary <string, string>
            {
                { "jsonp", jQuery },
                { "ui_mode", "web" },
                { "access_token", _accessToken }, //special id, like SteamId but not for some reason
                { "_", UnixTimeNow().ToString() }
            };

            string response = _web.Fetch(url, "GET", data, _account.AuthContainer, false).ReadStream();

            //returns an annoying JSON string that can't quite be deserialized yet
            response = StripjQueryArtifacts(response);
            //remove /**/jQuery11110010656769154593349_1442204142816( and remove )

            WebPresenceOAuthLogonResponse webPresenceOAuthLogonResponse =
                JsonConvert.DeserializeObject <WebPresenceOAuthLogonResponse>(response);

            _message = webPresenceOAuthLogonResponse.Message;
            return(webPresenceOAuthLogonResponse);
        }
        public GetTopicsHtmlResult GetTopicsHtml(ulong forumId, ulong start, ulong count)
        {
            string url = string.Format(TopicUrl, forumId) + "render/0/";

            var data = new Dictionary <string, string>
            {
                { "start", start.ToString() },
                { "count", count.ToString() }
            };

            return(_web.Fetch(url, "POST", data, _account.AuthContainer).DeserializeJson <GetTopicsHtmlResult>());
        }
Beispiel #7
0
        /// <summary>
        /// Requests the inventory for the specified steamId and appId.
        /// </summary>
        /// <param name="steamId">steamId64 of the inventory to request.</param>
        /// <param name="appId">App ID of the inventory to request.</param>
        /// <returns>Returns a dynamic JSON object of the inventory to request.</returns>
        private dynamic RequestInventory(uint appId)
        {
            string url = "https://steamcommunity.com/profiles/" + _steamId + "/inventory/json/" + appId + "/2/";

            return(JsonConvert.DeserializeObject <dynamic>(_web.Fetch(url, "GET", null, null, false).ReadStream()));
        }
        /// <summary>
        /// Posts a comment to the specified profile.
        /// </summary>
        /// <param name="steamId">The SteamId64 of the profile to post to.</param>
        /// <param name="comment">The comment text.</param>
        /// <param name="Account.Account.AuthContainer">Auth Cookies MUST be passed here, the function will fail if not.</param>
        /// <returns>A CommentResponse object.</returns>
        public CommentResponse PostComment(ulong steamId, string comment)
        {
            string url = "https://steamcommunity.com/comment/Profile/post/" + steamId + "/-1/";

            string sessionid =
                (from Cookie cookie in _account.AuthContainer.GetCookies(new Uri("https://steamcommunity.com"))
                 where cookie.Name == "sessionid"
                 select cookie.Value).FirstOrDefault();

            var data = new Dictionary <string, string>
            {
                { "comment", comment },
                { "sessionid", sessionid }
            };

            return
                (_web.Fetch(url, "POST", data, _account.AuthContainer, true, url.Substring(0, url.Length - 3))
                 .DeserializeJson <CommentResponse>());
        }