You can do this using the WinHttpRequest object
<%
Dim http: Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
Dim url: url = "https://www.instamojo.com/api/1.1/payment-requests/"
Dim data: data = "allow_repeated_payments=False&amount=2500&buyer_name=John+Doe&purpose=FIFA+16&redirect_url=http%3A%2F%2Fwww.example.com%2Fredirect%2F&phone=9999999999&send_email=True&webhook=http%3A%2F%2Fwww.example.com%2Fwebhook%2F&send_sms=True&email=foo%40example.com"
With http
Call .Open("POST", url, False)
Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call .SetRequestHeader("X-Api-Key", "yourvalue")
Call .SetRequestHeader("X-Auth-Token", "yourvalue")
Call .Send(data)
End With
If Left(http.Status, 1) = 2 Then
'Request succeeded with a HTTP 2xx response, do something...
Else
'Output error
Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
End If
%>
This is just a hard-coded example, usually you would build the data
variable via some method rather then passing a hard-coded string.
What about Response.AddHeader()
?
Response.AddHeader()
is used in Classic ASP to set HTTP headers being returned to the client when the server is sending a response.
In this scenario the ASP page is the client sending a request to another server so in this context you wouldn't use Response.AddHeader
but the SetRequestHeader()
method of the WinHttpRequest
object instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…