ASP检测客户是否取消微信公众号
时间:2021-05-23 23:59:08
收藏:0
阅读:0
有时因为项目内需要用到检测客户是否已经取消关注微信公众号,只有没被取消执行相关模板信息发送、图文信息发送、视频语音等信息发送给客户才有意义。也可以知道多少客户还在我们的微信公众号关注内。方便后期做公众号营销。废话不多数了直接上代码。
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 Dim WxObj 13 Set WxObj = Server.CreateObject("WeixinDLL.WeixinClass") 14 WxObj.SetAppID = "AppID" 15 WxObj.SetAppSecret = "AppSecret" 16 17 Dim token 18 token = WxObj.Get_Token ‘ 当前用户的access_token 19 If Trim(token) = "" Or IsNull(token) Then Response.Write "没有获取到有效的access_token,导致模板消息发送失败!" : Response.End() 20 21 Dim pJson 22 pJson = WxObj.IfCancelWX(C_CeoOpenID, token) 23 pJson = Trim(pJson) 24 If Cstr(pJson) = "0" Then 25 Response.Write "取消关注" 26 ElseIf Cstr(pJson) = "1" Then 27 Response.Write "已关注" 28 ElseIf Cstr(pJson) = "2" Then 29 Response.Write "非法OpenID" 30 End If 31 Set WxObj = Nothing 32 If Err Then Response.Write Err.Description 33 %> 34 </body> 35 </html>
注意上述程序用到了 WeixinDLL 组件,如需要此组件者,可以联系我:z18670092211
评论(0)