我在payment.asp
中使用asp classic和vb-script编写代码。我使用winhttprequest将数据发布到第三方并成功提交,但它的工作正常但我的问题是:
发布数据后,在第三方网页上创建了一个唯一的ID,我想在同一页面上检索payment.asp
如何检索第三方创建的唯一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
%>
请帮帮我。
答案 0 :(得分:1)
Apparently API的结果采用JSON格式。因此,您需要一个像ASPJSON这样的JSON解析器。
在aspJSON1.17.asp
和payment.asp
中加入Set oJSON = New aspJSON
oJSON.loadJSON http.ResponseText
Response.Write oJSON.data("payment_request")("id")
获得201状态代码的响应后,解析ID如下:
>>> collections.OrderedDict({key:filter(lambda x:not x.endswith('ing'), value) for key,value in dictionary.items()})
OrderedDict([('two', ['goodbye']), ('one', ['hello'])])