微信带链接的文本消息推送

微信推送消息时,推送带链接的文本消息

                            string token = “你的access_token”;
                            StringBuilder sb = new StringBuilder();
                            sb.Append("{\"touser\":\"发送对象的openid\",\"msgtype\":\"text\",\"text\":{\"content\":\"您好!,请前往<a href='http://www.baidu.com '>百度</a>查看\"}}");
                            string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}", token);
                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                            byte[] requestBytes = Encoding.UTF8.GetBytes(sb.ToString());
                            request.Method = "POST";
                            request.ContentType = "application/x-www-form-urlencoded";
                            request.ContentLength = requestBytes.Length;
                            Stream requestStream = request.GetRequestStream();
                            requestStream.Write(requestBytes, 0, requestBytes.Length);
                            requestStream.Close();
                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
                            string backstr = sr.ReadToEnd();
                            
                            sr.Close();
                            response.Close();

注意:

超级链接中 URL 要用单引号 " ' "

 

转载于:https://www.cnblogs.com/bsyblog/p/7339885.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值