Beispiel #1
0
        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://www.999dice.com/api/web.aspx")
            };
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
            List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();

            pairs.Add(new KeyValuePair <string, string>("a", "CreateAccount"));
            pairs.Add(new KeyValuePair <string, string>("key", "7a3ada10cb804ec695cda315db6b8789"));
            FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
            string responseData           = "";

            using (var response = Client.PostAsync("", Content))
            {
                try
                {
                    responseData = response.Result.Content.ReadAsStringAsync().Result;
                }
                catch (AggregateException e)
                {
                    if (e.InnerException.Message.Contains("ssl"))
                    {
                        return(Register(username, password));
                    }
                }
            }

            d999Register tmp = json.JsonDeserialize <d999Register>(responseData);

            if (tmp.SessionCookie != "" && tmp.SessionCookie != null)
            {
                sessionCookie = tmp.SessionCookie;
                pairs         = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("a", "CreateUser"));
                pairs.Add(new KeyValuePair <string, string>("key", "7a3ada10cb804ec695cda315db6b8789"));
                pairs.Add(new KeyValuePair <string, string>("s", sessionCookie));
                pairs.Add(new KeyValuePair <string, string>("Username", username));
                pairs.Add(new KeyValuePair <string, string>("Password", password));
                Content      = new FormUrlEncodedContent(pairs);
                responseData = "";
                using (var response = Client.PostAsync("", Content))
                {
                    try
                    {
                        responseData = response.Result.Content.ReadAsStringAsync().Result;
                    }
                    catch (AggregateException e)
                    {
                        if (e.InnerException.Message.Contains("ssl"))
                        {
                            return(Register(username, password));
                        }
                    }
                }

                Parent.updateBalance((decimal)(balance));
                Parent.updateBets(0);
                Parent.updateLosses(0);
                Parent.updateProfit(0m);
                Parent.updateWagered(0m);
                Parent.updateWins(0);
                Parent.updateDeposit(tmp.DepositAddress);
                uid = tmp.Accountid;
            }
            else
            {
            }
            return(sessionCookie != "" && sessionCookie != null);
        }