元生康SCRM系统博客
元生康SCRM系统包含了:CRM、OA、微信V3支付、考试、学院百科、财务、推广、CMS、代理加盟、抽奖、积分、现金券、在线充值活动、及时语音转化技术子系统等

现在很多客户互动方面都是需要发送提醒消息或通知类信息,下面我给大家详细介绍一下ASP项目中,用到发送微信服务号模板消息的功能。直接上代码。

注意:本功能用到了WeixinDLL组件(简洁高效)。另外自己也要去公众号加自己需要的模板,获取模板ID替换本代码内的模板ID即可

 1 <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
 2 <!DOCTYPE html>
 3 <html>
 4 <head>
 5   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 6   <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
 7   <title>发送模板消息</title>
 8 </head>
 9 <body>
10 <%
11  On Error Resume Next
12 
13  Dim WxObj
14  Set WxObj = Server.CreateObject("WeixinDLL.WeixinClass")
15  WxObj.SetAppID      = "AppID"
16  WxObj.SetAppSecret  = "AppSecret"
17  
18  Dim token,template_id,redirect_url,top_color,mode_data:mode_data=""
19  token = WxObj.Get_Token() ' 当前用户的access_token
20  If Trim(token) = "" Or IsNull(token) Then Response.Write "没有获取到有效的access_token,导致模板消息发送失败!" : Response.End()
21  ' 以发货通知为例(模板自己去公众号选择然后使用即可)
22  template_id  = "c_cLPaFSoovueuqv03msQJFRj2kGkNmK7g3jb6TUZ-w"     ' 模板ID
23  redirect_url = "https://www.domain.com/url.asp"      ' 点开更多消息链接
24  top_color    = "#5cb85c"                                         ' 标题字的颜色
25  mode_data = "{""first"":{ ""value"":""曾先生您好!您的订单已发货!"", ""color"":""#173177"" },"      ' 消息标题
26  mode_data = mode_data & """keyword1"":{ ""value"":""顺丰快递"", ""color"":""#173177"" },"   ' 快递公司
27  mode_data = mode_data & """keyword2"": { ""value"":""SF52365236252"", ""color"":""#173177"" },"   ' 快递单号
28  mode_data = mode_data & """keyword3"": { ""value"":""元森美品牌系列产品"", ""color"":""#173177"" },"        ' 品牌说明
29  mode_data = mode_data & """keyword4"": { ""value"":""10盒元森美水果酵素"", ""color"":""#173177"" },"        ' 产品内容
30  mode_data = mode_data & """remark"":{ ""value"":""微信公众号有快递信息提示,如未收到请及时与我公司电话联系:0731-82762612。"", ""color"":""#173177"" }"
31  mode_data = mode_data & "}"
32  
33  Dim pJson
34  pJson = WxObj.SendModeMessege(OpenID, template_id, redirect_url, top_color, mode_data, token)
35  Response.Write pJson
36 
37  Set WxObj = Nothing
38  If Err Then Response.Write Err.Description
39 %>
40 </body>
41 </html>

本功能用到了WeixinDLL组件,如有需要可以加微信:z18670092211,获取之后自己直接进行测试!

posted on 2021-05-04 10:42  元森美  阅读(587)  评论(0)    收藏  举报