public static void GetSummaries(SteamWeb web, SessionData session, ulong[] steamids, SummaryCallback summariesCallback) { web.Request(ApiEndpoints.USER_SUMMARIES_URL + "?access_token=" + session.OAuthToken + "&steamids=" + string.Join(",", steamids.Select(steamid => steamid.ToString()).ToArray()), "GET", (response, code) => { summariesCallback(code != HttpStatusCode.OK ? new Players() : JsonConvert.DeserializeObject <Players>(response ?? string.Empty)); }); }
private void _getConfirmationDetails(SteamWeb web, Confirmation conf, ConfirmationCallback callback) { string url = ApiEndpoints.COMMUNITY_BASE + "/mobileconf/details/" + conf.ID + "?"; this.GenerateConfirmationQueryParams(web, "details", queryString => { url += queryString; var cookies = new CookieContainer(); this.Session.AddCookies(cookies); this.GenerateConfirmationUrl(web, referer => { web.Request(url, "GET", null, cookies, (response, code) => { if (string.IsNullOrEmpty(response) || code != HttpStatusCode.OK) { callback(null); return; } var confResponse = JsonConvert.DeserializeObject <ConfirmationDetailsResponse>(response); callback(confResponse); }); }); }); }
private void _sendConfirmationAjax(SteamWeb web, Confirmation conf, string op, BCallback callback) { this.GenerateConfirmationQueryParams(web, op, queryParams => { string url = ApiEndpoints.COMMUNITY_BASE + "/mobileconf/ajaxop"; string queryString = "?op=" + op + "&"; queryString += queryParams; queryString += "&cid=" + conf.ID + "&ck=" + conf.Key; url += queryString; var cookies = new CookieContainer(); this.Session.AddCookies(cookies); web.Request(url, "GET", null, cookies, (response, code) => { if (response == null || code != HttpStatusCode.OK) { callback(false); return; } var confResponse = JsonConvert.DeserializeObject <SuccessResponse>(response); callback(confResponse.Success); }); }); }
public void FetchConfirmations(SteamWeb web, FcCallback callback) { this.GenerateConfirmationUrl(web, url => { var cookies = new CookieContainer(); this.Session.AddCookies(cookies); web.Request(url, "GET", null, cookies, (response, code) => { var ret = new List <Confirmation>(); if (response == null || code != HttpStatusCode.OK) { // Forbidden = family view, NotFound = bad token callback(ret, code == HttpStatusCode.Forbidden ? null : new WgTokenInvalidException()); return; } // Was it so hard? var doc = new HtmlDocument(); doc.LoadHtml(response); HtmlNode list = doc.GetElementbyId("mobileconf_list"); if (list == null || response.Contains("<div>Nothing to confirm</div>")) { callback(ret, null); return; } IEnumerable <HtmlNode> entries = list.Descendants("div").Where(child => child.Attributes["class"]?.Value == "mobileconf_list_entry"); foreach (HtmlNode node in entries) { // Look now, html is complicated string[] desc = node.Descendants("div").First(child => child.Attributes["class"].Value == "mobileconf_list_entry_description").Descendants("div").Select(elem => elem.InnerText).ToArray(); ret.Add(new Confirmation { Description = desc[0], Description2 = desc[1], DescriptionTime = desc[2], ID = int.Parse(node.GetAttributeValue("data-confid", "0")), Key = node.GetAttributeValue("data-key", "") }); } callback(ret, null); }); }); }
/// <summary> /// Refreshes the Steam session. Necessary to perform confirmations if your session has expired or changed. /// </summary> /// <returns></returns> public void RefreshSession(SteamWeb web, BfCallback callback) { string url = ApiEndpoints.MOBILEAUTH_GETWGTOKEN; var postData = new Dictionary <string, string>(); postData.Add("access_token", this.Session.OAuthToken); web.Request(url, "POST", postData, (response, code) => { if (response == null || code != HttpStatusCode.OK) { callback(Success.Error); return; } try { var refreshResponse = JsonConvert.DeserializeObject <WebResponse <RefreshSessionDataResponse> >(response); if (string.IsNullOrEmpty(refreshResponse?.Response?.Token)) { callback(Success.Failure); return; } string token = this.Session.SteamID + "%7C%7C" + refreshResponse.Response.Token; string tokenSecure = this.Session.SteamID + "%7C%7C" + refreshResponse.Response.TokenSecure; this.Session.SteamLogin = token; this.Session.SteamLoginSecure = tokenSecure; Storage.PushStore(this.Session); callback(Success.Success); } catch (Exception) { callback(Success.Error); } }); }