Exemple #1
0
        public async Task <int> GetStock(GameGate game)
        {
            try
            {
                this.client.DefaultRequestHeaders.Add("Authorization", "Bearer " + this.AccessToken);
                HttpResponseMessage httpResponseMessage = await client.GetAsync(game.GetStockApi);

                var exec = await httpResponseMessage.Content.ReadAsStringAsync();

                JObject data = JObject.Parse(exec);
                if ((int)data["c"] == 0)
                {
                    dynamic jsd = JObject.Parse(data["d"].ToString());
                    this.StockBalance = (int)jsd.stockBalance;
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(1);
        }
Exemple #2
0
        public async Task <int> GetInfo(GameGate game)
        {
            this.Status = "Đang Running";
            //HttpClient client = new HttpClient();
            JObject js = new JObject();

            js["Md5Password"] = Utils.MD5(this.Password);
            js["Username"]    = this.Username;
            js["Password"]    = this.Password;
            var content = new StringContent(js.ToString(), Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage httpResponseMessage = await this.client.PostAsync(game.LoginApi, content);

                var exec = await httpResponseMessage.Content.ReadAsStringAsync();

                JObject data = JObject.Parse(exec);

                if ((int)data["c"] != 0)
                {
                    this.Status = "Sai Mật Khẩu";
                }
                else
                {
                    this.Status      = "Thành Công";
                    this.AccessToken = data["m"].ToString();
                    dynamic jsd = JObject.Parse(data["d"].ToString());
                    this.Nickname    = jsd.nickname;
                    this.GoldBalance = (int)jsd.goldBalance;
                    this.CoinBalance = (int)jsd.coinBalance;
                    this.VipPoint    = (int)jsd.vipPoint;
                    this.Mobile      = jsd.mobile;
                    await GetStock(game);
                }
                return(1);
            }
            catch (Exception e)
            {
                this.Status = e.ToString();
                return(1);
            }
        }