如何使用 asp classic 使用 winhttprequest 获取数据
how to get data using winhttprequest using asp classic
我在 payment.asp
中使用 asp 经典和 vb 脚本编写了代码。我正在使用 winhttprequest 将数据发布到第 3 方并成功提交并且工作正常但我的问题是:
发布数据后,在第 3 方页面上,创建了一个我想在同一页面上检索的唯一 ID payment.asp
如何检索由第 3 方创建的唯一 ID。
我的代码如下:
<%
Dim http, url, data
Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
url = "https://www.instamojo.com/api/1.1/payment-requests/"
data = "amount=" & amount & "&buyer_name=" & buyer_name & "&purpose=" & purpose & "&redirect_url=" & redirect_url & "&phone=" & phone & "&send_email=" & send_email & "&send_sms=" & send_sms & "&email=" & email & ""
With http
Call .Open("POST", url, False)
Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call .SetRequestHeader("X-Api-Key", "[X-Api-Key]")
Call .SetRequestHeader("X-Auth-Token", "[X-Auth-Token]")
Call .Send(data)
End With
If http.Status = 201 Then
Call Response.Write("succeeded: " & http.Status & " " & http.StatusText)
Else
Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
End If
%>
请帮助我。
Apparently the API's results are formatted in JSON. So you'll need a JSON parser like ASPJSON.
在您的 payment.asp
中包含 aspJSON1.17.asp
和
收到 201 状态码的响应后,像这样解析 ID:
Set oJSON = New aspJSON
oJSON.loadJSON http.ResponseText
Response.Write oJSON.data("payment_request")("id")
我在 payment.asp
中使用 asp 经典和 vb 脚本编写了代码。我正在使用 winhttprequest 将数据发布到第 3 方并成功提交并且工作正常但我的问题是:
发布数据后,在第 3 方页面上,创建了一个我想在同一页面上检索的唯一 ID payment.asp
如何检索由第 3 方创建的唯一 ID。
我的代码如下:
<%
Dim http, url, data
Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
url = "https://www.instamojo.com/api/1.1/payment-requests/"
data = "amount=" & amount & "&buyer_name=" & buyer_name & "&purpose=" & purpose & "&redirect_url=" & redirect_url & "&phone=" & phone & "&send_email=" & send_email & "&send_sms=" & send_sms & "&email=" & email & ""
With http
Call .Open("POST", url, False)
Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call .SetRequestHeader("X-Api-Key", "[X-Api-Key]")
Call .SetRequestHeader("X-Auth-Token", "[X-Auth-Token]")
Call .Send(data)
End With
If http.Status = 201 Then
Call Response.Write("succeeded: " & http.Status & " " & http.StatusText)
Else
Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
End If
%>
请帮助我。
Apparently the API's results are formatted in JSON. So you'll need a JSON parser like ASPJSON.
在您的 payment.asp
中包含 aspJSON1.17.asp
和
收到 201 状态码的响应后,像这样解析 ID:
Set oJSON = New aspJSON
oJSON.loadJSON http.ResponseText
Response.Write oJSON.data("payment_request")("id")