基于asp的知識比較少 我自己寫了一個判斷是否關(guān)注公眾號的asp代碼
如下
<%@Language="VBScript" CodePage="65001"%>
<script language="jscript" runat="server">
function getjson(str){
try{
eval("var jsonStr = (" + str + ")");
}catch(ex){
var jsonStr = null;
}
return jsonStr;
}
</script>
<%
Response.Charset = "utf-8"
Function RequestUrl(url)
Set XmlObj = Server.CreateObject("Microsoft.XMLHTTP")
XmlObj.open "GET",url, false
XmlObj.send
If XmlObj.Readystate=4 Then
RequestUrl = XmlObj.responseText
Else
Response.Write("xmlhttp請求超時!")
Response.End()
End If
Set XmlObj = nothing
End Function
set obj = getjson(requesturl("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx10099df1be92c8ec&secret=0bfb784ee519131c55eb127c58255d7a")) ’此處獲得全局access_token
set objok=getjson(requesturl("https://api.weixin.qq.com/cgi-bin/user/info?access_token="&obj.access_token&"&openid=oET6uw2V79Ukj4-tJ8cGEHWhUAns")) '此處通過全局access_token獲取subscribe值
response.Write objok.subscribe
如果 subscribe
值為0為未關(guān)注
如果為1為已關(guān)注
%>
把a(bǔ)ppid和secret換成自己的微信公眾號的信息即可