首页 > 代码库 > 微信带链接的文本消息推送
微信带链接的文本消息推送
微信推送消息时,推送带链接的文本消息
string token = “你的access_token”; StringBuilder sb = new StringBuilder(); sb.Append("{\"touser\":\"发送对象的openid\",\"msgtype\":\"text\",\"text\":{\"content\":\"您好!,请前往<a href=http://www.mamicode.com/‘http://www.baidu.com ‘>百度查看/"}}"); 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 要用单引号 " ‘ "
微信带链接的文本消息推送
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。