美文网首页
2018-04-06

2018-04-06

作者: wuhuiwenzi | 来源:发表于2018-05-28 19:43 被阅读0次
      using (var httpClient = new HttpClient(new HttpClientHandler
                {
                    AutomaticDecompression = DecompressionMethods.GZip,
                }))
                {
                    var url = "https://dl.reg.163.com/l";
                    var publicKey = GetPublicKey();
                    var pwd = EncryptPassword(publicKey, password);
                    var initResult = await Init();
                    var gtResult = await GetGtResult(username);
    
                    if (gtResult.ret != "201")
                        throw new HttpRequestException(gtResult.ret);
    
                    httpClient.DefaultRequestHeaders.Clear();
                    httpClient.DefaultRequestHeaders.Add("Connection", "keep-alive");
                    httpClient.DefaultRequestHeaders.Add("Origin", "https://dl.reg.163.com");
                    httpClient.DefaultRequestHeaders.Add("Accpet", "*/*");
                    httpClient.DefaultRequestHeaders.Add("Referer", "https://dl.reg.163.com/src/mp-agent-finger.html?WEBZJVersion=1519802537259&pkid=hJWZDGT&product=subscribe");
                    httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh-CN,zh;q=0.9");
                    httpClient.DefaultRequestHeaders.Add("Cookie", cookies);
    
                    var postdata = new
                    {
                        un = username,
                        pw = pwd,
                        pd = "subscribe",
                        l = 1,
                        d = 10,
                        t = Util.Helpers.Time.GetUnixTimestamp13().ToString(),
                        pkid = "hJWZDGT",
                        domains = "",
                        tk = gtResult.tk,
                        pwdKeyUp = 1,
                        topURL = "http://mp.163.com/login.html?url=http://mp.163.com/index.html"
                    };
    
                    var stringContent = new StringContent(JsonConvert.SerializeObject(postdata), Encoding.UTF8, "application/json");
    
                    var response = await httpClient.PostAsync(url, stringContent);
    
                    var responseContent = await response.Content.ReadAsStringAsync();
    
                    var result = JsonConvert.DeserializeObject<LoginResult>(responseContent);
                    return result;
                }
    

    相关文章

      网友评论

          本文标题:2018-04-06

          本文链接:https://www.haomeiwen.com/subject/arfehftx.html