本文共 1092 字,大约阅读时间需要 3 分钟。
客服消息发送比较简单
注:指定openid和消息内容使用Post发送就可以,很多时候需要在触发事件或相应的情况下发送
官方文档:
1.获取发送地址
////// 客服发送消息-POST/// ///public string GetKFSend(){ string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}", config.Access_Token); return url;}
2.Post发送文本消息
////// 发送文本消息/// /// ///public string SendText(string openid, string content){ string url = new LinkManage().GetKFSend(); JObject data = new JObject(); data.Add("touser", openid); data.Add("msgtype", "text"); data.Add("text", JObject.FromObject(new { content = content })); string result = NetHelper.Post(url, data.ToString()); return result;}
3.Post发送图片消息
////// 发送图片消息/// /// /// ///public string SendImage(string openid, string media_id){ string url = new LinkManage().GetKFSend(); JObject data = new JObject(); data.Add("touser", openid); data.Add("msgtype", "image"); data.Add("image", JObject.FromObject(new { media_id = media_id })); string result = NetHelper.Post(url, data.ToString()); return result;}
需要请求帮助类的自行下载:
更多:
转载地址:http://gxogi.baihongyu.com/