网上的版本很多,带就是没有asp版
前端
var access_token=""
var CorpId="***********"
var xmlhttp;
if (window.XMLHttpRequest)
{
// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
xmlhttp=new XMLHttpRequest();
}
else
{
// IE6, IE5 浏览器执行代码
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
function token(code)
{
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
access_token=xmlhttp.responseText;
//var bb=JSON.parse(access_token)
//access_token=bb.access_token//
document.getElementById("myDiv0").innerHTML=access_token
//loadXMLDoc(access_token)
}
}
xmlhttp.open("GET","/dd/dd.asp?code="+code,true);
xmlhttp.send();
}
/*
function loadXMLDoc(access_t)
{
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
bb=xmlhttp.responseText;
//var bb=JSON.parse(access_token)
document.getElementById(“myDiv”).innerHTML=bb//
}
}
xmlhttp.open(“GET”,"/dd/dd.asp?token="+access_t,true);
xmlhttp.send();
}*/
后端
<%
Response.Addheader “Content-Type”,“text/html;charset=gb2312”
code=request.querystring(“code”)
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject(“adodb.stream”)
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
function getHTTPPage(url)
dim Http
set Http=server.createobject(“MSXML2.XMLHTTP”)
Http.open “GET”,url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
'getHTTPPage=Http.responseBody19f538914891314bac7c7a0008e3ea49
getHTTPPage=bytesToBSTR(Http.responseBody,“UTF-8”)
set http=nothing
if err.number<>0 then err.Clear
end function
appkey="//"
appsecret=""
url0=“https://oapi.dingtalk.com/gettoken?appkey=”&appkey&"&appsecret="&appsecret
Dim access
Dim json
'asp解溪json
Dim sc4Json,arr0
InitScriptControl
json = getHTTPPage(url0)
Set jsonobj=getJSONObject(json)
access_token =sc4Json.Eval(“jsonObject.access_token”)
url1=“https://oapi.dingtalk.com/user/getuserinfo?access_token=”&access_token&"&code="&code
json = getHTTPPage(url1)
%>
<%=json%>
<%
'asp解溪json
Sub InitScriptControl
Set sc4Json = Server.CreateObject(“MSScriptControl.ScriptControl”)
sc4Json.Language = “JavaScript”
sc4Json.AddCode “var itemTemp=null;function getJSArray(arr, index){itemTemp=arr[index];}”
End Sub
Function getJSONObject( strJSON )
sc4Json.AddCode "var jsonObject = " & strJSON
Set getJSONObject = sc4Json.CodeObject.jsonObject
End Function
%>