//public List<string> GetUserInfoList() { // var list = new List<string>(); // var openIdList = this.GetUserList(); // foreach (var openId in openIdList) // { // var userInfo = this.GetUserInfo(openId); // list.Add(userInfo); // } // return list; //} public string CreateMenu() { var url = string.Format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", this.GetToken()); var data = "{\"button\": [{\"type\": \"click\",\"name\": \"汪俊\",\"key\": \"V1002_TODAY_MUSIC\"}]}"; var res = WeChatAPI.HttpPost(url, data); return(res); }
public string GetTokenByCode(string code) { var appId = "wx0d5f15121f4d9cc3"; var secret = "c2dd349ae5faf6267bf330b44a7f8d50"; var url = string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", appId, secret, code); return(WeChatAPI.HttpGet(url)); }
/// <summary> /// 获取微信服务器IP地址 [OK] /// </summary> /// <returns></returns> public string GetWeChatServerIpList() { var url = $"https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token={this.GetToken()}"; var res = WeChatAPI.HttpGet(url); Console.WriteLine(res); return(res); }
/// <summary> /// 获取用户基本信息 [OK] /// </summary> /// <param name="openId"></param> /// <returns></returns> public string GetUserInfo() { var openId = "olMck1QEOgWG-pyofd1vhQJ1_kbk"; var url = string.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN", this.GetToken(), openId); var res = WeChatAPI.HttpGet(url); Console.WriteLine(res); return(res); }
/// <summary> /// 获取用户列表 [OK] /// </summary> /// <returns></returns> public string GetUserList() { var list = new List <string>(); var url = string.Format("https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}", this.GetToken(), string.Empty); var res = WeChatAPI.HttpGet(url); Console.WriteLine(res); return(res); }
/// <summary> /// 获取access_token [OK] /// </summary> /// <returns></returns> public string GetToken() { var url = string.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", this.appId, this.appSecret); var res = WeChatAPI.HttpGet(url); Console.WriteLine(res); var token = JSON.ToObject <Dictionary <string, object> >(res)["access_token"]; return(token.ToString()); }
/// <summary> /// 设置用户备注名 [OK] /// </summary> /// <returns></returns> public string UpdateUserRemark() { var url = $"https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=" + this.GetToken(); var postData = new { openid = "olMck1QEOgWG-pyofd1vhQJ1_kbk", remark = "汪俊" }; var res = WeChatAPI.HttpPost(url, JSON.ToJson(postData)); return(res); }
public static WeChatAPI GetInstance() { var inst = new WeChatAPI(); return(inst); }