-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.asp
More file actions
65 lines (48 loc) · 1.89 KB
/
request.asp
File metadata and controls
65 lines (48 loc) · 1.89 KB
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
<%response.charset = "utf-8"%>
<!--#include file="index_HMAC.asp" -->
<!--#include file="config.asp" -->
<!--#include file="utils.asp" -->
<%
function RequestAPI(resourcePath, oJSON)
Dim dateStr, salt, dateSalt, signature
Dim oXMLHTTP, resultJSON
dateStr = ToIsoDateTime(Now)
salt = RandomString()
dateSalt = dateStr & salt
signature = generateSHA256(dateSalt, apiSecret)
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "POST", serviceHost & resourcePath, False
oXMLHTTP.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
oXMLHTTP.setRequestHeader "Authorization", "HMAC-SHA256 apiKey=" & apiKey & ", date=" & dateStr & ", salt=" & salt & ", signature=" & signature
oXMLHTTP.Send oJSON.JSONoutput()
Set resultJSON = New aspJSON
If oXMLHTTP.Status <> 200 AND debugEnabled = True Then
Response.Write oXMLHTTP.statusText
Response.Write oXMLHTTP.responseText
End If
resultJSON.loadJSON(oXMLHTTP.responseText)
Set oXMLHTTP = Nothing
Set RequestAPI = resultJSON
end function
function RequestGET(resourcePath)
Dim dateStr, salt, dateSalt, signature
Dim oXMLHTTP, resultJSON
dateStr = ToIsoDateTime(Now)
salt = RandomString()
dateSalt = dateStr & salt
signature = generateSHA256(dateSalt, apiSecret)
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
oXMLHTTP.Open "GET", serviceHost & resourcePath, False
oXMLHTTP.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
oXMLHTTP.setRequestHeader "Authorization", "HMAC-SHA256 apiKey=" & apiKey & ", date=" & dateStr & ", salt=" & salt & ", signature=" & signature
oXMLHTTP.Send
Set resultJSON = New aspJSON
If oXMLHTTP.Status <> 200 AND debugEnabled = True Then
Response.Write oXMLHTTP.statusText
Response.Write oXMLHTTP.responseText
End If
resultJSON.loadJSON(oXMLHTTP.responseText)
Set oXMLHTTP = Nothing
Set RequestGET = resultJSON
end function
%>