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-3 – 用Response调用的Ajax.BeginForm OnFailu
- 如何在asp.net上模拟同时的web请求?
- 我应该学习不了解MVC 1或2的asp.NET MVC 3吗?
- asp.net-mvc – 单声道或Windows上的主机ServiceStack,MVC3
- 如何在ASP.NET WebForm中使用Ninject注入依赖项?
- .NET Core中Object Pool的简单使用
- asp.net-mvc-3 – 如何配置DbContext以使用Oracle ODP.Net和
- asp.net – 如何使用httpErrors添加默认错误页面
- .net – App_LocalResources如何使用MVC?
- asp.net – 使用Razor有点像回到经典的asp
- 部署ASP.Net MVC应用程序的最便宜的方法是什么?
- asp.net-mvc – Razor:如何填写textarea?
- asp.net-mvc – 如何在将控件传递给View后调试AS
- asp.net:如何在button onclick上使用eventargs进
- asp.net文件上传解决方案(图片上传、单文件上传
- Windbg程序调试系列1-常用命令说明&示例
- asp.net-mvc – 避免@html.checkboxfor的foreach
- 从ASP.NET页面启动.NET DLL
- asp.net-mvc – Razor嵌套WebGrid
- asp.net-mvc-3 – MVC3剃须刀:是否可以渲染传统