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;
}
网友评论