void GetBalanceThread() { try { while (ispd) { if (accesstoken != "" && ((DateTime.Now - lastupdate).TotalSeconds > 60 || ForceUpdateStats)) { string sEmitResponse2 = Client.GetStringAsync("users/1?api_key=" + accesstoken).Result; pduser tmpu = json.JsonDeserialize <pduser>(sEmitResponse2); balance = tmpu.user.balance / 100000000.0m; //i assume bets = tmpu.user.bets; Parent.updateBalance((decimal)(balance)); Parent.updateBets(tmpu.user.bets); Parent.updateLosses(tmpu.user.losses); Parent.updateProfit(tmpu.user.profit / 100000000m); Parent.updateWagered(tmpu.user.wagered / 100000000m); Parent.updateWins(tmpu.user.wins); lastupdate = DateTime.Now; } Thread.Sleep(1000); } } catch { } }
void GetBalanceThread() { try { while (ispd) { if (accesstoken != "" && (DateTime.Now - lastupdate).TotalSeconds > 60) { HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/users/1?access_token=" + accesstoken); if (Prox != null) { betrequest.Proxy = Prox; } betrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; HttpWebResponse EmitResponse2 = (HttpWebResponse)betrequest.GetResponse(); string sEmitResponse2 = new StreamReader(EmitResponse2.GetResponseStream()).ReadToEnd(); pduser tmpu = json.JsonDeserialize <pduser>(sEmitResponse2); balance = tmpu.user.balance; //i assume bets = tmpu.user.bets; Parent.updateBalance((decimal)(balance / 100000000.0)); Parent.updateBets(tmpu.user.bets); Parent.updateLosses(tmpu.user.losses); Parent.updateProfit(tmpu.user.profit / 100000000m); Parent.updateWagered(tmpu.user.wagered / 100000000m); Parent.updateWins(tmpu.user.wins); lastupdate = DateTime.Now; } Thread.Sleep(1000); } } catch { } }
public override bool Register(string Username, string Password) { ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null };; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://api.primedice.com/api/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); try { List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >(); pairs.Add(new KeyValuePair <string, string>("username", Username)); pairs.Add(new KeyValuePair <string, string>("affiliate", "seuntjie")); FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs); string sEmitResponse = Client.PostAsync("register", Content).Result.Content.ReadAsStringAsync().Result; pdlogin tmp = json.JsonDeserialize <pdlogin>(sEmitResponse); accesstoken = tmp.api_key; if (accesstoken == "") { return(false); } else { string sEmitResponse2 = Client.GetStringAsync("users/1?api_key=" + accesstoken).Result; pduser tmpu = json.JsonDeserialize <pduser>(sEmitResponse2); try { string s = ""; { s = getDepositAddress(); } if (s != null) { Parent.updateDeposit(s); } } catch { } balance = tmpu.user.balance; //i assume bets = tmpu.user.bets; Thread.Sleep(500); pairs = new List <KeyValuePair <string, string> >(); pairs.Add(new KeyValuePair <string, string>("password", Password)); Content = new FormUrlEncodedContent(pairs); string sEmitResponse3 = Client.PostAsync("password?api_key=" + accesstoken, Content).Result.Content.ReadAsStringAsync().Result; tmp = json.JsonDeserialize <pdlogin>(sEmitResponse); accesstoken = tmp.api_key; lastupdate = DateTime.Now; ispd = true; Thread t = new Thread(GetBalanceThread); t.Start(); return(true); } } catch { } return(false); }
public override void Login(string Username, string Password, string otp) { //accept-encoding:gzip, deflate, ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null }; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://api.primedice.com/api/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); try { /*if (Password.Length < 100) * { * * List<KeyValuePair<string, string>> pairs = new List<KeyValuePair<string, string>>(); * pairs.Add(new KeyValuePair<string, string>("username", Username)); * pairs.Add(new KeyValuePair<string, string>("password", Password)); * if (!string.IsNullOrWhiteSpace(otp)) * { * pairs.Add(new KeyValuePair<string, string>("otp", otp)); * } * * FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs); * string sEmitResponse = Client.PostAsync("login", Content).Result.Content.ReadAsStringAsync().Result; * if (sEmitResponse == "Invalid Password") * { * finishedlogin(false); * return; * } * pdlogin tmp = json.JsonDeserialize<pdlogin>(sEmitResponse); * accesstoken = tmp.api_key; * * } * else*/ accesstoken = Password; if (accesstoken == "") { finishedlogin(false); } else { string sEmitResponse2 = Client.GetStringAsync("users/1?api_key=" + accesstoken).Result; pduser tmpu = json.JsonDeserialize <pduser>(sEmitResponse2); this.username = tmpu.user.username; uid = tmpu.user.userid; balance = tmpu.user.balance; //i assume bets = tmpu.user.bets; Parent.updateBalance((decimal)(balance / 100000000.0m)); Parent.updateBets(tmpu.user.bets); Parent.updateLosses(tmpu.user.losses); Parent.updateProfit(tmpu.user.profit / 100000000m); Parent.updateWagered(tmpu.user.wagered / 100000000m); string s = tmpu.user.address; try { if (s == null) { s = getDepositAddress(); } if (s != null) { Parent.updateDeposit(s); } } catch { } Parent.updateWins(tmpu.user.wins); lastupdate = DateTime.Now; ispd = true; Thread t = new Thread(GetBalanceThread); t.Start(); finishedlogin(true); } } catch (WebException e) { if (e.Response != null) { } finishedlogin(false); } catch (Exception e) { finishedlogin(false); } }
public override bool Register(string Username, string Password) { try { HttpWebRequest RegRequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/register"); RegRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; if (Prox != null) { RegRequest.Proxy = Prox; } RegRequest.Method = "POST"; string post = "username="******"&affiliate=seuntjie"; RegRequest.ContentLength = post.Length; using (var writer = new StreamWriter(RegRequest.GetRequestStream())) { writer.Write(post); } HttpWebResponse EmitResponse = (HttpWebResponse)RegRequest.GetResponse(); string sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd(); pdlogin tmp = json.JsonDeserialize <pdlogin>(sEmitResponse); accesstoken = tmp.access_token; if (accesstoken == "") { return(false); } else { HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/users/1?access_token=" + accesstoken); if (Prox != null) { betrequest.Proxy = Prox; } betrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; HttpWebResponse EmitResponse2 = (HttpWebResponse)betrequest.GetResponse(); string sEmitResponse2 = new StreamReader(EmitResponse2.GetResponseStream()).ReadToEnd(); pduser tmpu = json.JsonDeserialize <pduser>(sEmitResponse2); string s = ""; { s = getDepositAddress(); } if (s != null) { Parent.updateDeposit(s); } //Parent.updateDeposit(tmpu.user.address); balance = tmpu.user.balance; //i assume bets = tmpu.user.bets; Thread.Sleep(500); HttpWebRequest PWRequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/password?access_token=" + accesstoken); if (Prox != null) { PWRequest.Proxy = Prox; } PWRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; PWRequest.Method = "POST"; post = "password=" + Password;; PWRequest.ContentLength = post.Length; using (var writer = new StreamWriter(PWRequest.GetRequestStream())) { writer.Write(post); } HttpWebResponse EmitResponse3 = (HttpWebResponse)PWRequest.GetResponse(); string sEmitResponse3 = new StreamReader(EmitResponse3.GetResponseStream()).ReadToEnd(); lastupdate = DateTime.Now; return(true); } } catch { } return(false); }
public override void Login(string Username, string Password, string otp) { try { HttpWebRequest loginrequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/login"); if (Prox != null) { loginrequest.Proxy = Prox; } loginrequest.Method = "POST"; //loginrequest.TransferEncoding = "UTF-8"; string post = "username="******"&password="******"&otp=" + otp : ""); loginrequest.ContentLength = post.Length; loginrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; using (var writer = new StreamWriter(loginrequest.GetRequestStream())) { writer.Write(post); } HttpWebResponse EmitResponse = (HttpWebResponse)loginrequest.GetResponse(); string sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd(); pdlogin tmp = json.JsonDeserialize <pdlogin>(sEmitResponse); accesstoken = tmp.access_token; if (accesstoken == "") { finishedlogin(false); } else { HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/users/1?access_token=" + accesstoken); if (Prox != null) { betrequest.Proxy = Prox; } betrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; HttpWebResponse EmitResponse2 = (HttpWebResponse)betrequest.GetResponse(); string sEmitResponse2 = new StreamReader(EmitResponse2.GetResponseStream()).ReadToEnd(); pduser tmpu = json.JsonDeserialize <pduser>(sEmitResponse2); this.username = tmpu.user.username; uid = tmpu.user.userid; balance = tmpu.user.balance; //i assume bets = tmpu.user.bets; Parent.updateBalance((decimal)(balance / 100000000.0)); Parent.updateBets(tmpu.user.bets); Parent.updateLosses(tmpu.user.losses); Parent.updateProfit(tmpu.user.profit / 100000000m); Parent.updateWagered(tmpu.user.wagered / 100000000m); string s = tmpu.user.address; if (s == null) { s = getDepositAddress(); } if (s != null) { Parent.updateDeposit(s); } Parent.updateWins(tmpu.user.wins); lastupdate = DateTime.Now; finishedlogin(true); } } catch (WebException e) { if (e.Response != null) { } finishedlogin(false); } }