首页 > PHP资讯 > 工具库 > 微信公众号查看关注者接口的.NET实例教程

微信公众号查看关注者接口的.NET实例教程

工具库
实体类:

 public class userlist  {    public string total { get; set; }    public string count { get; set; }    public userlistopenid data { get; set; }    public string next_openid { get; set; }  }
 public class userlistopenid  {    public List openid { get; set;  }
 public class userdetail  {    public int subscribe { get; set; }    public string openid { get; set; }    public string nickname { get; set; }    public int sex { get; set; }    public string language { get; set; }    public string city { get; set; }    public string province { get; set; }    public string country { get; set; }    public string headimgurl { get; set; }    public int subscribe_time { get; set; }    public string unionid { get; set; }    public string remark { get; set; }    public int groupid { get; set; }    public int[] tagid_list { get; set; }  }

getUser.aspx代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="getUser.aspx.cs" Inherits="MyTest.WebUI.Manager.usermsg.getUser" %>          
      

", jsapi_ticket, noncestr, timestamp.ToString()); signature = GetSHA1(s1); return signature; } public static string GetSHA1(string strSource) { string strResult = string.Empty; System.Security.Cryptography.SHA1 sha = System.Security.Cryptography.SHA1.Create(); byte[] bytResult = sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(strSource)); for (int i = 0; i < bytResult.Length; i++) { strResult = strResult + bytResult[i].ToString("x2"); } return strResult; } //SHA1哈希加密算法 public static string GetSHA1_1(string str_sha1_in) { SHA1 sha1 = new SHA1CryptoServiceProvider(); byte[] bytes_sha1_in = Encoding.Default.GetBytes(str_sha1_in); byte[] bytes_sha1_out = sha1.ComputeHash(bytes_sha1_in); string str_sha1_out = BitConverter.ToString(bytes_sha1_out); str_sha1_out = str_sha1_out.Replace("-", "").ToLower(); return str_sha1_out; } // 判断是否超过7200s public static long CheckTimeOut(DateTime changeTime) { return Convert.ToInt64((DateTime.Now - changeTime).TotalSeconds); } } # region 创建Json序列化 及反序列化类目 //创建JSon类 保存文件 ticket.txt public class AccToken { public string access_token { get; set; } public long expires_in { get; set; } } //创建从微信返回结果的一个类 用于获取ticket public class JsTicket { public long errcode { get; set; } public string errmsg { get; set; } public string ticket { get; set; } public long expires_in { get; set; } } #endregion

JSon序列化,反序列化


public class JsonEntityExchange where T:new()  {    ///     /// json转实体LIST    ///     /// 
    ///     public static string Entity2Json(List lists) {      return new JavaScriptSerializer().Serialize(lists);    }  }

结果如图:

以上就是微信公众号查看关注者接口的.NET实例教程的详细内容,更多请关注php中文网其它相关文章!

工具库

本文由欣才IT学院整理发布,未经许可,禁止转载。
支持48不支持0