wanglizhong
2025-05-05 41332c9a8b1164dba70930f93f6a67abad4fc7fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Session.CodePage=65001%>
<!--#include virtual="/inc/odbc.asp"-->
<%weixinID = Request("weixinAPPid")
scene_id = Request("QR_ID")
QR_Name=Request("QR_Name")
QR_type=Request("QR_type")
QR_Key=Request("QR_Key")
QRNew=Request("QRNew")%>
<!docType html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<title>微信二维码接口</title>
<%If weixinID="" Then weixinID=1
If scene_id="" And (QR_type="" Or QR_Key="") Then  response.end%>
<!--#include virtual="/inc/JsonPost.asp"-->
</head>
<body>
<center>
 
<%'Response.end
    'ID验证
    If scene_id<>"" Then
        sql="select * from weixinQR where QR_ID="&scene_id
    Else
        sql="select * from weixinQR where QR_type="&QR_type&" and QR_Key='"&QR_Key&"'"
    End If
    rs.open sql,objConn,1,1
    If rs.eof Then
        QR_ticket=""
        If scene_id="" Then
            rs.close()
            sql="select top 1 QR_ID from weixinQR where QR_ID<100000 order by QR_ID desc"
            rs.open sql,objConn,1,1
            If not rs.eof Then
                scene_id=CSng(rs(0))+1
            Else
                scene_id=1
            End If
        End If
        If QR_type=1 Then        '车牌
            
        ElseIf QR_type=2 Then    '人员
 
        Else
            QR_type=0
        End If
        sql="Insert into weixinQR (QR_ID,QR_Name,QR_type,QR_Key) values ("&scene_id&",'"&QR_Name&"',"&QR_type&",'"&QR_Key&"')"
        objConn.Execute sql
        QR_Time=DateAdd("s",2592000,Now) 
    Else
        scene_id=CSng(rs("QR_ID"))
        QR_Name=rs("QR_Name")
        QR_type=rs("QR_type")
        QR_ticket=rs("QR_ticket")
        QR_url=rs("QR_url")
        QR_Time=DateAdd("s",2592000,rs("QR_Time"))
        If InStr(QR_url,"errmsg")>0 Then QR_url=null
    End If
 
    rs.close()
 
    '二维码生成
    If (QR_ticket="" Or isnull(QR_ticket)) Or QRNew=1 Or QR_Time<Now()  Or isnull(QR_url) then
        appUrl="https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="&access_token
 
        If scene_id>100000 Then
            '微信临时二维码请求
            QR_type=0
            args1="{"
            args1=args1&"""expire_seconds"": 2592000,"    '该二维码有效时间,以秒为单位。 最大不超过604800(即7天)。
            args1=args1&"""action_name"": ""QR_SCENE"","    '二维码类型,QR_SCENE为临时,QR_LIMIT_SCENE为永久,QR_LIMIT_STR_SCENE为永久的字符串参数值
            args1=args1&"""action_info"": {""scene"": {"    '二维码详细信息
            args1=args1&"""scene_id"": "&scene_id&""    '场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000)
            args1=args1&"}}"
            'args1=args1&"""scene_str"": """&touser&""","    '场景值ID(字符串形式的ID),字符串类型,长度限制为1到64,仅永久二维码支持此字段
            args1=args1&"}"
            'Response.Write appUrl&"<br>"&args1 &"<br><br><br>"
 
        Else
            '微信永久二维码请求
            QR_type=1
            args1="{""action_name"": ""QR_LIMIT_SCENE"", ""action_info"": {""scene"": {""scene_id"": "&scene_id&"}}}"
 
        End If 
        'Response.Write appUrl&"<br><br>"
        HTMLCODE= PostBody(appUrl,args1)
        'Response.Write HTMLCODE &"<br><br>"
        QR_ticket=replace(HTMLCODE,"{""ticket"":""","")
        QR_ticket=Left(QR_ticket,InStr(QR_ticket,"""")-1)
        QR_url=Mid(HTMLCODE,InStr(HTMLCODE,"""url"":""")+7)
        QR_url=Mid(QR_url,1,InStr(QR_url,"""}")-1)
        QR_url=replace(QR_url,"\/","/")
        If InStr(QR_url,"40001")=0 Then
            sql="update weixinQR set QR_ticket='"&QR_ticket&"',QR_url='"&QR_url&"',QR_Time=getdate() where QR_ID="&scene_id
            objConn.Execute sql
        End If
 
    End If
QR_ticket=Replace(QR_ticket,"\/","/")
'Response.Write ticket &"<br>"
If QR_Name="" And scene_id>100000 Then QR_Name="微信临时二维码"
%>微信扫一扫二维码<br>
<img src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=<%=QR_ticket%>" width="80%" border="0" alt="" style="max-width: 430px;">
 
<br>
<%=QR_Name%><br>
<!--ticket:<%=QR_ticket%><br>-->
标题:<%=weixinTitle%><br>
<%If weixinPic<>"" then%><img src="<%=weixinPic%>" width="100%" border="0" alt="" style="max-width:300px;"><br><%End If%>
内容:<%=weixinTXT%><br>
<a href="<%=weixinURL%>" target="_blank"><%=weixinURL%></a><br>
 
<%If QR_type=0 Then
    Response.Write "有效期至:"&QR_Time
  Else
    Response.Write "永久二维码"
  End If
%>
<br><br>二维码连接:<%=QR_url%>
<br>二维码设计:<a href="http://cli.im/url" target="_blank">点击这里</a>
</body>
</html>