在做微信开发时候,经常要用到Access Token,但是官网提供的都是基于php写的,我用asp写了,有需要可以直接复制去用,模板消息,jdk上传图片,客服消息等全需要这个:
'获取 access_token
Public Function Get_Access_Token()
sCode = Request("code")
If sCode ="" And Session("access_token")="" Then
Response.Redirect(GetAuthorization_Code)
Else
If DateDiff("s",Now,Session("access_token_expires"))> 0 Then
Exit Function
End If
End If
Dim url, params,Temp
Url="https://api.weixin.qq.com/sns/oauth2/access_token?"
params = "appid="&s_APPID
params = params & "&secret=" & s_APPSECRET
params = params & "&code=" & sCode
params = params & "&grant_type=authorization_code"
url = Url & params
Temp=RequestUrl(url,"GET","")
'Die Temp
If CheckData(Temp,"access_token") = True Then
set obj = getjson(Temp)
if isobject(obj) Then
Session("access_token") = obj.access_token
Session("access_token_expires") = DateAdd("s",obj.expires_in,Now)
Session("openid") = obj.openid
End If
set obj = Nothing
Else
Response.Write("Get_Access_Token()=>"&Temp)
Response.End()
End If
End Function
=======================================
学习交流微信:18611436777