//public AzureLevelItem GetCurrentLevelData() //{ // return myAzureLevelData[currentLevel - 1]; //} public void InitializeLevelData() { WebAPI myWebAPI = new WebAPI(); string response = myWebAPI.Get("http://azurewebapihuntsman.azurewebsites.net/api/WordGameLevels"); myAzureLevelData = JsonConvert.DeserializeObject<AzureLevelItemList>(response); //Save(); //Load(); }
/// <summary> /// This maps to the D(Delete) part of the CRUD operation. /// </summary> public HttpResponseMessage Delete(WebAPI.Models.ProjectClassification tax) { //session state is enabled for WebAPI in the global.ascx CustomSecurity.User u = (CustomSecurity.User)HttpContext.Current.Session["user"]; if (u == null || u.IsEmpty()) return Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid user"); try { if (ProjectMgmt.Taxonomy.DeleteFromProject(ConfigurationManager.ConnectionStrings["SystemDS"].ToString(), tax.TID, new Guid(tax.PID))) { return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.NotModified, ProjectMgmt.Taxonomy.GetLastError.Message); } } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } }
internal List <Steam.TradeOffer> GetTradeOffers() { if (string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) { return(null); } KeyValue response = null; using (dynamic iEconService = WebAPI.GetInterface("IEconService", Bot.BotConfig.SteamApiKey)) { iEconService.Timeout = Timeout; for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) { try { response = iEconService.GetTradeOffers( get_received_offers: 1, active_only: 1, secure: !Program.GlobalConfig.ForceHttp ); } catch (Exception e) { Logging.LogGenericException(e, Bot.BotName); } } } if (response == null) { Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName); return(null); } List <Steam.TradeOffer> result = new List <Steam.TradeOffer>(); foreach (KeyValue trade in response["trade_offers_received"].Children) { Steam.TradeOffer tradeOffer = new Steam.TradeOffer { tradeofferid = trade["tradeofferid"].AsString(), accountid_other = (uint)trade["accountid_other"].AsUnsignedLong(), // TODO: Correct this when SK2 with https://github.com/SteamRE/SteamKit/pull/255 gets released trade_offer_state = trade["trade_offer_state"].AsEnum <Steam.TradeOffer.ETradeOfferState>() }; foreach (KeyValue item in trade["items_to_give"].Children) { tradeOffer.items_to_give.Add(new Steam.Item { appid = item["appid"].AsString(), contextid = item["contextid"].AsString(), assetid = item["assetid"].AsString(), classid = item["classid"].AsString(), instanceid = item["instanceid"].AsString(), amount = item["amount"].AsString(), }); } foreach (KeyValue item in trade["items_to_receive"].Children) { tradeOffer.items_to_receive.Add(new Steam.Item { appid = item["appid"].AsString(), contextid = item["contextid"].AsString(), assetid = item["assetid"].AsString(), classid = item["classid"].AsString(), instanceid = item["instanceid"].AsString(), amount = item["amount"].AsString(), }); } result.Add(tradeOffer); } return(result); }
public void BeginBingoReqString() { this.is_begin = true; this.sb = WebAPI.GetStringBuilder(); this.sb.Append("\"bingoprogs\":["); }
public ReqGoogleReview(Network.ResponseCallback response) { this.name = "serial/register/greview"; this.body = WebAPI.GetRequestString(WebAPI.GetStringBuilder().ToString()); this.callback = response; }
public ReqTowerSupporter(Network.ResponseCallback response) { this.name = "tower/supportlist"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
public ReqFriendApprove(string fuid) { fuid = WebAPI.EscapeString(fuid); this.name = "friend/approve"; this.body = WebAPI.GetRequestString("\"fuid\":\"" + fuid + "\""); }
public ReqGachaExec(string gachaid, Network.ResponseCallback response) { this.name = "gacha/exec"; this.body = WebAPI.GetRequestString("\"gachaid\":\"" + gachaid + "\""); this.callback = response; }
public ReqCoinConvert(Network.ResponseCallback response) { this.name = "shop/event/coinconvert"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
private YouTube.RSS WebApiModelToDALObject(WebAPI.Models.YouTube data) { YouTube.RSS utube = new YouTube.RSS(); try { utube.RSSID = new Guid(data.RSSID); utube.Name = data.Name; utube.Icon = data.Icon; utube.Description = data.Description; return utube; } catch (Exception ex) { return null; } }
public ReqVersusLobby(Network.ResponseCallback response) { this.name = "vs/lobby"; this.body = WebAPI.GetRequestString(string.Empty); this.callback = response; }
public ReqLoginPack(Network.ResponseCallback response) { this.name = "login/param"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
public ReqTrophyProgress() { this.name = "trophy"; this.body = WebAPI.GetRequestString(null); }
public void Excluir(int id) { string json = WebAPI.RequestDELETE("deleteClient", id.ToString()); }
public ReqBtlColo(Network.ResponseCallback response) { this.name = "btl/colo"; this.body = WebAPI.GetRequestString(WebAPI.GetStringBuilder().ToString()); this.callback = response; }
public ReqBtlColoReset(ColoResetTypes reset, Network.ResponseCallback response) { this.name = "btl/colo/reset/" + reset.ToString(); this.body = WebAPI.GetRequestString(WebAPI.GetStringBuilder().ToString()); this.callback = response; }
public static async Task <bool> AuthenticateUser() { SteamUser.WebAPIUserNonceCallback nonce; try { nonce = await Steam.Instance.User.RequestWebAPIUserNonce(); } catch (Exception e) { IsAuthorized = false; Log.WriteWarn("WebAuth", "Failed to get nonce: {0}", e.Message); return(false); } // 32 byte random blob of data var sessionKey = CryptoHelper.GenerateRandomBlock(32); byte[] encryptedSessionKey; // ... which is then encrypted with RSA using the Steam system's public key using (var rsa = new RSACrypto(KeyDictionary.GetPublicKey(Steam.Instance.Client.Universe))) { encryptedSessionKey = rsa.Encrypt(sessionKey); } // users hashed loginkey, AES encrypted with the sessionkey var encryptedLoginKey = CryptoHelper.SymmetricEncrypt(Encoding.ASCII.GetBytes(nonce.Nonce), sessionKey); using (var userAuth = WebAPI.GetAsyncInterface("ISteamUserAuth")) { KeyValue result; try { result = await userAuth.CallAsync(HttpMethod.Post, "AuthenticateUser", 1, new Dictionary <string, string> { { "steamid", Steam.Instance.Client.SteamID.ConvertToUInt64().ToString() }, { "sessionkey", WebHelpers.UrlEncode(encryptedSessionKey) }, { "encrypted_loginkey", WebHelpers.UrlEncode(encryptedLoginKey) }, } ); } catch (HttpRequestException e) { IsAuthorized = false; Log.WriteWarn("WebAuth", "Failed to authenticate: {0}", e.Message); return(false); } File.WriteAllText(Path.Combine(Application.Path, "files", ".support", "cookie.txt"), $"steamLogin={result["token"].AsString()}; steamLoginSecure={result["tokensecure"].AsString()}"); Cookies = new CookieContainer(); Cookies.Add(new Cookie("steamLogin", result["token"].AsString(), "/", "store.steampowered.com")); Cookies.Add(new Cookie("steamLoginSecure", result["tokensecure"].AsString(), "/", "store.steampowered.com")); } IsAuthorized = true; Log.WriteInfo("WebAuth", "Authenticated"); return(true); }
/// <summary> /// This maps to the C(Create) part of the CRUD operation. This will create a new entry for the /// current data that is being sent to the server /// </summary> /// <param name="value"></param> public HttpResponseMessage Post(WebAPI.Models.RSS rss) { //session state is enabled for WebAPI in the global.ascx CustomSecurity.User u = (CustomSecurity.User)HttpContext.Current.Session["user"]; if (u == null || u.IsEmpty()) return Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid user"); try { RSS.RSS r = this.WebApiModelToDALObject(rss); if (r.Add(ConfigurationManager.ConnectionStrings["SystemDS"].ToString())) { return Request.CreateResponse<WebAPI.Models.RSS>(System.Net.HttpStatusCode.Created, rss); } else { return Request.CreateResponse(HttpStatusCode.InternalServerError, RSS.RSS.GetLastError.Message); } } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } }
public ReqChatChannelAutoAssign(Network.ResponseCallback response) { this.name = "chat/channel/auto"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
private EventMessage.EventMessage convertFromEventMessage(WebAPI.Models.EventMessage data) { EventMessage.EventMessage msg = new EventMessage.EventMessage(); try { msg.EventID = data.EventID; msg.Level = (EventMessage.EventLevel)Convert.ToInt16(data.Level); msg.Action = (EventMessage.EventAction)Convert.ToInt16(data.Action); msg.Result = (EventMessage.EventResult)Convert.ToInt16(data.Result); msg.Application = data.Application; msg.ApplicationVersion = data.ApplicationVersion; msg.OperationCode = data.OperationCode; msg.KeyWords = data.Keywords; msg.EventDateTime = Convert.ToDateTime(data.EventDateTime); msg.UID = (data.UID == null) ? Guid.Empty : new Guid(data.UID); msg.IP = data.IP; msg.URL = data.URL; return msg; } catch (Exception ex) { return null; } }
public void Inserir() { string jsondata = JsonConvert.SerializeObject(this); string json = WebAPI.RequestPOST("registrar", jsondata); }
public ReqSendAlterData(Network.ResponseCallback response) { this.name = "master/log"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
public void Atualizar() { string jsondata = JsonConvert.SerializeObject(this); string json = WebAPI.RequestPUT("atualizar/" + Id, jsondata); }
public ReqGachaHistory(Network.ResponseCallback response) { this.name = "gacha/history"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
public ReqItemComposit(string iname, Network.ResponseCallback response) { this.name = "item/gousei"; this.body = WebAPI.GetRequestString("\"iname\":\"" + iname + "\""); this.callback = response; }
public void WebAPIAsyncHasDefaultTimeout() { var iface = WebAPI.GetAsyncInterface(new Uri("https://whatever/"), "ISteamWhatever"); Assert.Equal(iface.Timeout, TimeSpan.FromSeconds(100)); }
public ReqFriendReq(string fuid) { this.name = "friend/req"; this.body = WebAPI.GetRequestString("\"fuid\":\"" + fuid + "\""); }
public ReqEventShopList(Network.ResponseCallback response) { this.name = "shop/event/shoplist"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
public static WWW RequestPrivateQuiz(string quizID) { WebAPI.apiPlace = "/quiz/private/" + quizID + "/"; return(WebAPI.Get()); }
internal bool Init(SteamClient steamClient, string webAPIUserNonce, string parentalPin) { if (steamClient == null || steamClient.SteamID == null || string.IsNullOrEmpty(webAPIUserNonce)) { return(false); } ulong steamID = steamClient.SteamID; string sessionID = Convert.ToBase64String(Encoding.UTF8.GetBytes(steamID.ToString())); // Generate an AES session key byte[] sessionKey = CryptoHelper.GenerateRandomBlock(32); // RSA encrypt it with the public key for the universe we're on byte[] cryptedSessionKey; using (RSACrypto rsa = new RSACrypto(KeyDictionary.GetPublicKey(steamClient.ConnectedUniverse))) { cryptedSessionKey = rsa.Encrypt(sessionKey); } // Copy our login key byte[] loginKey = new byte[webAPIUserNonce.Length]; Array.Copy(Encoding.ASCII.GetBytes(webAPIUserNonce), loginKey, webAPIUserNonce.Length); // AES encrypt the loginkey with our session key byte[] cryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey); // Do the magic Logging.LogGenericInfo("Logging in to ISteamUserAuth...", Bot.BotName); KeyValue authResult; using (dynamic iSteamUserAuth = WebAPI.GetInterface("ISteamUserAuth")) { iSteamUserAuth.Timeout = Timeout; try { authResult = iSteamUserAuth.AuthenticateUser( steamid: steamID, sessionkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedSessionKey, 0, cryptedSessionKey.Length)), encrypted_loginkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedLoginKey, 0, cryptedLoginKey.Length)), method: WebRequestMethods.Http.Post, secure: !Program.GlobalConfig.ForceHttp ); } catch (Exception e) { Logging.LogGenericException(e, Bot.BotName); return(false); } } if (authResult == null) { return(false); } Logging.LogGenericInfo("Success!", Bot.BotName); string steamLogin = authResult["token"].AsString(); string steamLoginSecure = authResult["tokensecure"].AsString(); Cookie["sessionid"] = sessionID; Cookie["steamLogin"] = steamLogin; Cookie["steamLoginSecure"] = steamLoginSecure; // The below is used for display purposes only Cookie["webTradeEligibility"] = "{\"allowed\":0,\"reason\":0,\"allowed_at_time\":0,\"steamguard_required_days\":0,\"sales_this_year\":0,\"max_sales_per_year\":0,\"forms_requested\":0}"; if (!UnlockParentalAccount(parentalPin).Result) { return(false); } LastSessionRefreshCheck = DateTime.Now; return(true); }
public static WWW RequestPublicQuizzes() { WebAPI.apiPlace = "/quiz/public/"; return(WebAPI.Get()); }
public static WWW RequestVersion() { WebAPI.apiPlace = "/sysinfo/mobile-version/"; return(WebAPI.Get()); }
/// <summary> /// This maps to the U(Update) part of the CRUD operation. This protocol will update the current representation /// of the data on the remote server. /// </summary> public HttpResponseMessage Put(WebAPI.Models.ProjectTaxonomy tax) { //session state is enabled for WebAPI in the global.ascx CustomSecurity.User u = (CustomSecurity.User)HttpContext.Current.Session["user"]; //if (u == null || u.IsEmpty()) return Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid user"); try { ProjectMgmt.Taxonomy t = this.WebApiModelToDALObject(tax); if (t.Update(ConfigurationManager.ConnectionStrings["SystemDS"].ToString())) { return Request.CreateResponse<WebAPI.Models.ProjectTaxonomy>(System.Net.HttpStatusCode.OK, tax); } else { return Request.CreateResponse(HttpStatusCode.InternalServerError, ProjectMgmt.Taxonomy.GetLastError.Message); } } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } }
private RSS.RSS WebApiModelToDALObject(WebAPI.Models.RSS data) { RSS.RSS rss = new RSS.RSS(); try { rss.RSSID = new Guid(data.RSSID); rss.Name = data.Name; rss.Icon = data.Icon; rss.Description = data.Description; return rss; } catch (Exception ex) { return null; } }
private ProjectMgmt.Taxonomy WebApiModelToDALObject(WebAPI.Models.ProjectClassification data) { ProjectMgmt.Taxonomy tax = new ProjectMgmt.Taxonomy(); try { tax.TID = data.TID; tax.Name = data.Name; tax.Description = data.Description; tax.Weight = data.Weight; return tax; } catch (Exception ex) { return null; } }
public ReqVersusStatus() { this.name = "vs/status"; this.body = string.Empty; this.body = WebAPI.GetRequestString(this.body); }
private ProjectMgmt.Project WebApiModelToDALObject(WebAPI.Models.Project data) { ProjectMgmt.Project dal = new ProjectMgmt.Project(); try { dal.PID = new Guid(data.PID); dal.Icon = data.Icon; dal.Code = data.Code; dal.Name = data.Name; dal.Description = data.Description; dal.EstimatedStartDate = Convert.ToDateTime(data.EstimatedStartDate); dal.EstimatedEndDate = Convert.ToDateTime(data.EstimatedEndDate); dal.ActualStartDate = Convert.ToDateTime(data.ActualStartDate); dal.ActualEndDate = Convert.ToDateTime(data.ActualEndDate); dal.Folder = data.Folder; dal.Caption = data.Caption; dal.URL = data.URL; dal.Organization = data.Organization; return dal; } catch (Exception ex) { return null; } }
/// <summary> /// This maps to the C(Create) part of the CRUD operation. This will create a new entry for the /// current data that is being sent to the server /// </summary> /// <param name="value"></param> public HttpResponseMessage Post(WebAPI.Models.ProjectClassification tax) { //session state is enabled for WebAPI in the global.ascx CustomSecurity.User u = (CustomSecurity.User)HttpContext.Current.Session["user"]; if (u == null || u.IsEmpty()) return Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid user"); try { ////add taxonomy classification to project ProjectMgmt.Taxonomy t = this.WebApiModelToDALObject(tax); if (ProjectMgmt.Taxonomy.AddToProject(ConfigurationManager.ConnectionStrings["SystemDS"].ToString(), tax.TID, new Guid(tax.PID))) { return Request.CreateResponse<WebAPI.Models.ProjectClassification>(System.Net.HttpStatusCode.Created, tax); } else { return Request.CreateResponse(HttpStatusCode.InternalServerError, ProjectMgmt.Taxonomy.GetLastError.Message); } //return Request.CreateResponse<WebAPI.Models.ProjectTaxonomy>(System.Net.HttpStatusCode.Created, tax); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } }
public ReqItemAddStmPaid() { this.name = "item/addstmpaid"; this.body = WebAPI.GetRequestString(null); }
public ReqItemAddBoxPaid(long iid, Network.ResponseCallback response) { this.name = "item/addboxpaid"; this.body = WebAPI.GetRequestString((string)null); this.callback = response; }
/// <summary> /// This maps to the U(Update) part of the CRUD operation. This protocol will update the current representation /// of the data on the remote server. /// </summary> public HttpResponseMessage Put(WebAPI.Models.EventMessage message) { //session state is enabled for WebAPI in the global.ascx CustomSecurity.User u = (CustomSecurity.User)HttpContext.Current.Session["user"]; if (u == null || u.IsEmpty()) return Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid user"); try { //EventMessage.EventMessage ev = this.convertFromEventMessage(message); //if (ev.Update(ConfigurationManager.ConnectionStrings["SystemDS"].ToString())) //{ // return Request.CreateResponse<WebAPI.Models.EventMessage>(System.Net.HttpStatusCode.Created, message); //} //else //{ // return Request.CreateResponse(HttpStatusCode.InternalServerError, EventMessage.EventMessage.GetLastError.Message); //} return Request.CreateResponse<WebAPI.Models.EventMessage>(System.Net.HttpStatusCode.Created, message); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } }