小米网站登录源码C#版

一步一步做,肯定能成功 HttpHelper类请从网络上搜索

            string postData = getPostData();     

           HttpHelper ht = new HttpHelper();

            HttpItem item = new HttpItem()    

           {

                URL = "https://account.xiaomi.com/pass/serviceLoginAuth2",  

               Method = "POST",          

              Postdata = postData,      

             CookieContainer = new System.Net.CookieContainer(),

            ContentType = new MiLoginHttpHelper().contentType,     

            };  

           string html = ht.GetHtml(item).Html;

 

方法:getPostData()

   private string getPostData()     

     {

            string name = txtUName.Text.Trim();      

       string pwd = txtPwd.Text.Trim();      

       PostParaPair model = new PostParaPair();      

       model.Add(new PostParaPair() { Key = "_sign", Value = "R4cRs0JL2JfHHaPenjPG2c3Foa4=" });     

        model.Add(new PostParaPair() { Key = "callback", Value = "https://account.xiaomi.com/sts?sign=6aRtWvCpNNuCwNpKtdu9CEEJOL8%3D&followup=https%3A%2F%2Faccount.xiaomi.com%2Fpass%2FuserInfo&sid=passport" });

       model.Add(new PostParaPair() { Key = "qs", Value = "%3Fcallback%3Dhttps%253A%252F%252Faccount.xiaomi.com%252Fsts%253Fsign%253D6aRtWvCpNNuCwNpKtdu9CEEJOL8%25253D%2526followup%253Dhttps%25253A%25252F%25252Faccount.xiaomi.com%25252Fpass%25252FuserInfo%2526sid%253Dpassport%26sid%3Dpassport" });

       model.Add(new PostParaPair() { Key = "pwd", Value = pwd });      

       model.Add(new PostParaPair() { Key = "serviceParam", Value = "{\"checkSafePhone\":false}" });   

      model.Add(new PostParaPair() { Key = "sid", Value = "passport" });       

      model.Add(new PostParaPair() { Key = "user", Value = name });

      return model.ToString();        

}

类PostParaPair:

public class PostParaPair
{
    List<PostParaPair> paraList = new List<PostParaPair>();
    public string Key { get; set; }
    public string Value { get; set; }
    public void Add(PostParaPair para)
    {
        paraList.Add(para);
    }
    public override string ToString()
    {
        string reString = "";
        if (paraList.Count != 0)
        {
            foreach (PostParaPair item in paraList)
            {
                reString += string.Format("&{0}={1}", item.Key, CommonMethod.GetUrlEncode(item.Value));
            }
        }
        return reString.TrimStart('&');
    }
}

CommonMethod.GetUrlEncode:方法

    public static string GetUrlEncode(string content)
    {
        return System.Web.HttpUtility.UrlEncode(content, System.Text.Encoding.UTF8);
    }

转载于:https://www.cnblogs.com/magicsong/p/3996408.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值