api – 通过msxml2.ServerXMLHTTP提供身份验证信息
|
我正在使用Classic ASP并尝试使用JustGiving API. 我想用它在我的网站上显示我捐赠页面上收到的总金额和捐款总额. 我可以通过以下方式查看信息: <%
vurl = "http://api.justgiving.com/---myIDhere---/v1/account"
Set http = Server.CreateObject("msxml2.ServerXMLHTTP")
http.Open "GET",vurl,False
http.Send
Set dom = Server.CreateObject("msxml2.DOMDocument")
dom.loadXML http.responseText
Set items = dom.getElementsByTagName("account")
For Each item In items
Set var_totalDonated = item.getElementsByTagName("totalDonated")
If NOT (var_totalDonated IS Nothing) Then
var_totalDonated = ap(totalDonated(0).Text)
response.write var_totalDonated
End If
Next
%>
但是,当我访问它时页面超时. 我想这是因为我需要提供一些身份验证信息,如下所示: 所以我得到了身份验证信息. 但我不知道如何将它“发送”到API,以便它可以作为用户验证我并提供信息. 它还提到通过上面的链接提供标题信息(我不能发布链接,因为我没有足够的声誉),但用#contentTypes替换URL末尾的#protectedResources. 对不起 – 我还缺少那边的东西吗? 如果我问的是愚蠢的问题,我很抱歉,但是关于API文档的信息假定用户方面有一定程度的智能,而且我没有太多的信息! 任何建议都非常感谢. 谢谢 感谢John的回复. 基于此,我将代码更改为: <%
vurl = "https://api.justgiving.com/API_KEY/v1/account"
Set http = Server.CreateObject("msxml2.ServerXMLHTTP")
http.Open "GET",False,"username","pwd"
http.setTimeouts 5000,5000,10000,10000 ''ms - resolve,connect,send,receive
http.setRequestHeader "Authorization","Basic MY_AUTH_STRING"
http.Send
Set dom = Server.CreateObject("msxml2.DOMDocument")
dom.loadXML http.responseText
Set items = dom.getElementsByTagName("account")
For Each item In items
Set var_totalDonated = item.getElementsByTagName("totalDonated")
If NOT (var_totalDonated IS Nothing) Then
var_totalDonated = (var_totalDonated(0).Text)
response.write var_totalDonated
End If
Next
%>
但不幸的是,该页面仍然超时. 我也通过以下方式检查: 但到目前为止还没有答案. 再次感谢 修正版 <%
Sub debug( varName )
Dim varValue
varValue = Eval( varName )
response.write "<p style='margin:10px; border-bottom:2px solid #ccc;border-top:1px solid #eaeaea;background-color:white;padding:10px;color:red;text-align:left;'><strong>" & varName & "</strong>: " & varvalue & "</p>" & vbcrlf & vbcrlf
End Sub
vurl = "https://api.justgiving.com/AP_KEY/v1/account"
Set http = Server.CreateObject("msxml2.ServerXMLHTTP")
http.Open "GET",username,password
http.setTimeouts 5000,10000 'ms - resolve,"Basic AUTH_STRING"
http.Send
Response.ContentType = "application/xml"
Set dom = Server.CreateObject("msxml2.DOMDocument")
dom.loadXML http.responseText
Set items = dom.getElementsByTagName("account")
For Each item In items
Set var_totalDonated = item.getElementsByTagName("totalDonated")
If NOT (var_totalDonated IS Nothing) Then
var_totalDonated = ap(var_totalDonated(0).Text)
debug "var_totalDonated"
End If
Set var_totalRaised = item.getElementsByTagName("totalRaised")
If NOT (var_totalRaised IS Nothing) Then
var_totalRaised = ap(var_totalRaised(0).Text)
debug "var_totalRaised"
End If
Set var_totalGiftAid = item.getElementsByTagName("totalGiftAid")
If NOT (var_totalGiftAid IS Nothing) Then
var_totalGiftAid = ap(var_totalGiftAid(0).Text)
debug "var_totalGiftAid"
End If
Next
%>
以前我用过: vurl = "https://api.justgiving.com/AP_KEY/v1/account" 但是,当我将其更改为https时,它起作用了. 我以为我之前尝试过,但显然不是. 再次感谢John,非常感谢您的帮助! 解决方法尝试http.Open "GET","yourusername","yourpassword" 我不知道这是否适用于宽容,但它与Bing API有关 此外,这个问题可能是相关的 编辑 – 使用Response.ContentType和Msxml2.ServerXMLHTTP.6.0 vurl = "https://api.justgiving.com/API_KEY/v1/account"
Set http = Server.CreateObject("msxml2.ServerXMLHTTP.6.0")
http.Open "GET",receive'
http.setRequestHeader "Authorization","Basic MY_AUTH_STRING"
http.Send
Response.ContentType = "application/xml"
Set items = http.responseXML.getElementsByTagName("account")
等等 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – 我如何编写一个MVC3 / 4应用程序,它既可以作
- 如何为枚举执行asp.net mvc 4模型绑定?
- 如何在ASP.NET MVC中保留/保护Edit中的某些字段
- asp.net-mvc – HttpConfiguration缺少程序集
- ASP.NET MVC与Web客户端软件工厂(WCSF)
- asp.net-mvc – 为什么ASP.Net MVC便携式区域不像Rails插件
- asp.net-mvc – 向MVC 3添加基于声明的授权
- ASP.NET:请求cookie对于域名为null?
- asp.net-core-2.1 – 如何在asp.net Core 2.1.1中为Identit
- asp.net-mvc-3 – 用于ASP.NET MVC的Razor View Engine的源
- 加速ASP.Net网站或应用程序
- asp.net – 身份使用Web API授权属性角色
- asp.net-mvc – 什么是AsyncManager.Outstanding
- asp.net – Microsoft重写模块 – 强制www url或
- asp.net-mvc – 启用/禁用每个控制器/操作方法的
- 为什么这么多ASP.NET开发服务器实例?
- 在ASP.NET MVC 6中继续支持Ninject?
- asp.net-mvc – T4MVC @ Url.Action(MVC.Control
- asp.net-web-api2 – Web Api 2 Post – UrlHelp
- asp.net – 多个用户控件和JavaScript
