该应用为开发者提供了调用高德开放平台提供的API服务
的ASLP服务。
AppContext currentApp = SDK.getAppAPI().getAppContext("com.xxx");// 调用者的app,如天气预报应用
String aslp = "aslp://com.actionsoft.apps.addons.gaode/gaodeAPI";// 为PaaS上层应用提供的固定地址
Map<String, Object> params = new HashMap<>();
params.put("url", "https://restapi.amap.com/v3/weather/weatherInfo");// 需要在AWS PaaS控制台注册appKey
ResponseObject ro = SDK.getAppAPI().callASLP(currentApp, aslp, params);// 调用API,返回ASLP执行结果
if (ro.isOk()) {
JSONObject r = JSONObject.parseObject(ro.toString());
String result = (r.getJSONObject("data").getJSONObject("api").toJSONString());// 高德API返回的结果
System.out.println(result);// Test!
} else {
System.out.println(ro.toString());// Test!
}
AppContext currentApp = SDK.getAppAPI().getAppContext(WeatherConstant.APP_WEATHER);// 调用者的app,如天气预报应用
String aslp = "aslp://com.actionsoft.apps.addons.gaode/gaodeAPI";// 为PaaS上层应用提供的固定地址
Map<String, Object> params = new HashMap<>();
AppAPI appApi = SDK.getAppAPI();
params.put("url", "https://restapi.amap.com/v3/weather/weatherInfo");// 高德天气预报API名称,需要在AWS PaaS控制台注册appKey
JSONObject apiParams = new JSONObject();// 如果该API有查询参数
apiParams.put("city", cityId);// 高德天气预报API需要的参数
apiParams.put("extensions", isAll);//可选值:base/all base:返回实况天气 all:返回预报天气
params.put("apiParams", apiParams.toString());
ResponseObject ro = SDK.getAppAPI().callASLP(currentApp, aslp, params);// 调用API,返回ASLP执行结果
if (ro.isOk()) {
JSONObject r = JSONObject.parseObject(ro.toString());
String result = (r.getJSONObject("data").getJSONObject("api").toJSONString());// 高德API返回的结果
System.out.println(result);// Test!
} else {
System.out.println(ro.toString());// Test!
}