ASP的例子

下面的示例没有设置接受头,因此,响应在默认情况下返回XML格式。

示例请求

下面的代码调用获得所有项目为所有项目检索信息的API操作。

<%@ Language="JScript"%> <% //获取所有项目的完整信息-注意:必须使用&nextProjectId={some id}查询字符串参数迭代结果,因为响应一次只返回10个项目var url =" https://api.globalgiving.org/api/public/projectservice/all/projects?api_key=YOUR_API_KEY";var request = Server.CreateObject("Msxml2.ServerXMLHTTP");请求。open("GET", url, false);request.send ();var statusCode = request.status;var output = request.responseText;//输出任何错误开关(statusCode) {case 200: //成功中断;case 503: output = "服务不可用。"\n\n”+输出;打破; case 500: output = "Internal Server Error.\n\n" + output; break; case 401: output = "Unauthorized. You do not have permission to access this resource.\n\n" + output; break; case 403: output = "Forbidden. You do not have permission to access this resource.\n\n" + output; break; case 400: output = "Bad request.\n\n" + output; break; default: output = "Unexpected HTTP status of: " + statusCode + ".\n\n" + output; } // outputting results as plain text Response.ContentType = "text/plain"; Response.AddHeader("Content-Disposition", "inline"); Response.Write(output); %>

示例响应

<?xml version="1.0" encoding="UTF-8" standalone="是"?> <项目> true 364 <项目> <主动>true <活动>识字、英语和创收技能课程在亚洲特区妇女学习中心提供,每月为约540名妇女提供服务。贾格尔顿的诊所每月向2 500多名病人提供医疗保健和健康教育。 2006-10-11T17:21:55-07:00 Creating Hope International P. /contactAddress> O. Box 1058 Dearborn United States CHI@creatinghope.org Toc Dunlap(313) 278-5806 48121 Michigan President < contactturl >https://www.creatinghope.org country>Afghanistan  AF  25 15名女性将学会阅读。   50 5个妇女有裁缝课程的布料和工具。   <金额>75 <描述>42妇女接受基本保健和健康教育。   <供资>3908.0 <目标>7260 354 //www.tuuhangaido.com/pfil/354/pict.jpg 通过Jaghartun和Sar Asia的妇女学习中心为难以接触到的农村妇女和女童提供了全面的医疗和教育服务。 These centers improve the education and health of Afghan women in the region. No education has been available to women and girls in the western province of Herat, Afghanistan, for the last decade under the Taliban regime. Project partner AIL began offering Women’s Learning Centers to women and girls in rural Herat during 2003. These health and education services at Sar Asia and Jaghartun include a maternal/child health clinic, literacy and skills training classes. This project will ensure continuation of these urgently needed, accessible, culturally sensitive services. 33 //www.tuuhangaido.com/pr/400/proj354a.html#progressReports  //www.tuuhangaido.com/pr/400/proj354a.html Asia and Oceania 3352.0 active Empowering rural Afghan women and girls in Sar Asia and Jaghartun, Herat, through education and training opportunities as well as health and reproductive health services. Education Learning Centers for Rural Women in Herat
  . .  ......  
警告:Javascript当前已禁用或在您的浏览器中不可用。GlobalGiving大量使用Javascript,禁用Javascript后将无法正常运行。请启用Javascript并刷新此页。
Baidu
map