博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# 调用微信公众号接口发送客服消息示例
阅读量:4287 次
发布时间:2019-05-27

本文共 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/

你可能感兴趣的文章
iOS之苹果自带的json解析NSJSONSerialization(序列化)
查看>>
iOS中坐标转换
查看>>
论文笔记 | Leveraging Graph to Improve Abstractive Multi-Document Summarization
查看>>
NAACL2021丨Knowledge Guided Metric Learning for Few-Shot Text Classification
查看>>
论文笔记|Deep Open Intent Classification with Adaptive Decision Boundary
查看>>
【论文笔记】
查看>>
论文笔记_Pay Attention to MLPs
查看>>
【论文笔记】
查看>>
论文笔记
查看>>
论文笔记 | Attention-based LSTM for Aspect-level Sentiment Classification
查看>>
【论文笔记】Joint Extraction of Entities and Relations Based on a Novel Tagging Scheme
查看>>
论文笔记|Bidirectional LSTM-CRF Models for Sequence Tagging
查看>>
论文笔记:Constructing Narrative Event Evolutionary Graph for Script Event Prediction
查看>>
论文笔记: Hierarchical Chinese Legal event extraction via Pedal Attention Mechanism
查看>>
论文笔记 | Enhancing Pre-Trained Language Representations with Rich Knowledge for MRC
查看>>
论文笔记 | Text Summarization with Pretrained Encoders
查看>>
论文笔记:Document-level Event Extraction via Heterogeneous Graph-based Interaction Model with a Tracker
查看>>
论文笔记丨Inductive Unsupervised Domain Adaptation for Few-Shot Classification via Clustering
查看>>
论文笔记|GSum: A General Framework for Guided Neural Abstractive Summarization
查看>>
论文笔记 | Does Structure Matter? Encoding Documents for Machine Reading Comprehension
查看>>