下面的代码调用得到区域检索GlobalGiving项目分类的所有区域的API方法。
代码示例使用了Jakarta Commons HttpClient可以下载的库在这里.
进口org.apache.commons.httpclient.HttpClient;进口org.apache.commons.httpclient.methods.GetMethod;def getResponseText(url) {def get = new GetMethod(url) new HttpClient().executeMethod(get) BufferedInputStream bis = new BufferedInputStream(get. getresponsebodyasstream ()) return bis. gettext ('UTF-8')} def host = 'https://api.globalgiving.org' def operation = '/api/public/projectservice/regions' def api_key = 'YOUR_API_KEY' def url = "${host}${operation}?api_key=${api_key}"
<?XML版本="1.0" encoding="utf-8" standalone="yes"?> 非洲 亚洲和大洋洲 欧洲和俄罗斯 中东 北美 南/中美洲和加勒比