Ejemplo n.º 1
0
        private void webwxinit_new()
        {
            ShowMsg("webwxinit_new");
            if (__5)
            {
                SendHeader(httpclient, ReplaceHeaderKey(url_webwxinit[1]));
                byte[] bs   = Encoding.UTF8.GetBytes(ReplaceHeaderKey(@"{""BaseRequest"":{""Uin"":""{UIN}"",""Sid"":""{SID}"",""Skey"":""{SKEY}"",""DeviceID"":""{DeviceID}""}}"));
                string json = ReplaceHeaderKey(@"{""BaseRequest"":{""Uin"":""{UIN}"",""Sid"":""{SID}"",""Skey"":""{SKEY}"",""DeviceID"":""{DeviceID}""}}");
                string url  = ReplaceKey(url_webwxinit[0]);

                //var task = httpclient.PostAsync(ReplaceKey(url_webwxinit[0]), new ByteArrayContent(bs));
                {
                    //  string value = GetDeflateByStream(task.Result.Content.ReadAsStreamAsync().Result);
                    string value = HttpClientExt.RunPost(url, json);
                    //pick up loginer
                    Loginer  loginer = value.ConvertJson <Loginer>();
                    BaseUser me      = loginer.User.ConvertMapModel <User, BaseUser>();
                    mySelf         = me.ConvertMapModel <BaseUser, Friend>();
                    mySelf.IsOwner = 1;
                    //"Ret": 1100,
                    if (!value.Contains("\"Ret\": 0"))
                    {
                        ShowMsg("没有返回正确的数据,webwxinit错误!");
                        // throw new Exception("没有返回正确的数据,webwxinit错误!");
                    }

                    //USER_INFO
                    USER_INFO = SubString(value.Replace("\r", "").Replace("\n", ""), "\"User\": {", "NickName");
                    USER_INFO = SubString(USER_INFO, "\"UserName\": \"", "\",");


                    USER_NICKNAME = SubString(value.Replace("\r", "").Replace("\n", ""), "\"User\": {", "HeadImgUrl");
                    USER_NICKNAME = SubString(USER_NICKNAME, "\"NickName\": \"", "\",");


                    label1.Text = USER_INFO;
                    USER_DI.Add(USER_INFO, USER_NICKNAME);

                    this.Text = USER_NICKNAME + ">>>转发微信机器人 V0.5.1 20170502";

                    //SyncKey
                    SyncKey  = SubString(value.Replace("\r", "").Replace("\n", ""), "\"SyncKey\": ", "}]}");
                    SyncKey += "}]}";
#if DEBUG
                    this.txtTip.Text = SyncKey;
#endif
                }
            }
        }