private string RefreshAccessToken() { string text = "AccessToken-" + Appid; string text2 = Cache.ReadCache(text).ToMyString(); string result; if (text2 != "") { result = text2; } else { HttpHelper httpHelper = new HttpHelper(); HttpResult html = httpHelper.GetHtml(new HttpItem { URL = SystemExtends.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", new object[] { this.Appid, this.AppSecret }), Method = "GET" }); string html2 = html.Html; accessTokenResult accessTokenResult = SystemExtends.ToObject <accessTokenResult>(html2); Cache.AddCache(text, accessTokenResult.access_token, DateTime.Now.AddMilliseconds((double)(accessTokenResult.expires_in - 600))); result = accessTokenResult.access_token; } return(result); }
public WX_Response sendMessage(JsonResponse model) { string text = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}"; HttpHelper httpHelper = new HttpHelper(); HttpItem item = new HttpItem(); item.URL = SystemExtends.format(text, new object[] { this._accesstoken }); item.Encoding = Encoding.UTF8; item.PostEncoding = Encoding.UTF8; item.Method = "POST"; item.Postdata = model.ToJson().Replace("\\\\", "\\"); HttpResult html = httpHelper.GetHtml(item); string html2 = html.Html; return(SystemExtends.ToObject <WX_Response>(html2)); }