<%@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>
|