本人也是刚学企业微信api没多久,系列文章都是从初学者角度写的,适合零基础入门(非.net零基础),若有什么不足或不清楚的地方欢迎指出
本文是以mpnews类型的图文消息(带内容页的图文消息)为例
1.获取access_token
操作企业微信的每一个api都需要用到access_token
private string get_access_token()
{
//是否存在缓存
if (RedisCacheHelper.Exists(Rediskey))
{
//如果缓存中有access_token则不再调用api
return RedisCacheHelper.Get(Rediskey).ToString();
}
//请求企业微信api获取json格式数据
string result = HttpHelper.GetUrlString(
httpUrl: $"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={企业ID}&corpsecret={应用密钥}",
isProxy: true);
LogHelper.Debug(resu