public WebAuthRes GetAccessToken(string code, out string error) { var url = string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", _wechatAcountConf.AppId, _wechatAcountConf.AppSecret, code); var res = ApiServiceAgent.CallAPI <WebAuthRes>(url, out var errDes); error = errDes?.errmsg; //isReUse = errDes != null && errDes.errcode == 40163; return(res); }
public string SendTemplateMsg(TemplateMsgSendPara para) { var url = string.Concat("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=", GetAccessToken()); var paraStr = JsonConvert.SerializeObject(para); ErrorDes error; var res = ApiServiceAgent.CallAPI <ErrorDes>(url, paraStr, out error); if (res == null) { return("微信接口调用失败:" + error); } return(res.errcode == 0 ? null : "微信接口调用失败:" + res.errmsg); }
public UserInfoObj GetUserInfo(string openId) { var url = string.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN", GetAccessToken(), openId); ErrorDes error; var user = ApiServiceAgent.CallAPI <UserInfoObj>(url, out error); if (!string.IsNullOrEmpty(error?.errmsg)) { LogService.ErrorFormat("Wechat get user info error:{0}", error.errmsg); } return(user); }
public UserInfoObj GetUserInfo(string accessToken, string openId, out string error) { var url = string.Format("https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN", accessToken, openId); //返回数据: //{ // "openid": "o8V571O4OpXS9SvKAw9x1U9pl4i4", // "nickname": "404", // "sex": 1, // "language": "zh_CN", // "city": "", // "province": "尼古拉耶夫", // "country": "乌克兰", // "headimgurl": "http:\/\/thirdwx.qlogo.cn\/mmopen\/vi_32\/6LMUKXmCOeYTBorejJGehztNqeNLt69SiaYRtYeYOQo2ZqcDFUlGINpj01QfhEcXc4ia7r4qdxGZiawEv0FUphiatg\/132", // "privilege": [] //} var res = ApiServiceAgent.CallAPI <UserInfoObj>(url, out var errDes); error = errDes?.errmsg; return(res); }