API参数 ip_to_weatherweatherhistoryarea_to_idarea_to_weathergps_to_weatherphone_post_code_weatherhour24spot_to_weatherday15 调用地址: http,https://weather01.api.bdymkt.com/ip
请求方式: POST 支持格式: application/json;charset=UTF-8 调用工具: 去调试 请求参数(Headers) 请求参数(Query) 请求参数(Body) 请求参数(Path) 请求示例 javapythongocurlphpnodejs
示例代码使用, 需要使用Maven加入依赖 <dependency>
<groupId>com.baidubce</groupId>
<artifactId>api-explorer-sdk</artifactId>
<version>1.0.0</version>
</dependency>
import com.baidubce.http.ApiExplorerClient;
import com.baidubce.http.AppSigner;
import com.baidubce.http.HttpMethodName;
import com.baidubce.model.ApiExplorerRequest;
import com.baidubce.model.ApiExplorerResponse;
public class RequestDemo {
public static void main(String[] args) {
String path = "http://gwgp-ufzwheokmrq.n.bdcloudapi.com/ip";
ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);
request.setCredentials("您的 access key", "您的 secret key");
request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8");
ApiExplorerClient client = new ApiExplorerClient(new AppSigner());
try {
ApiExplorerResponse response = client.sendRequest(request);
System.out.println(response.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
}
点击复制代码
正常返回示例
{
"showapi_res_code": 0,
"showapi_res_error": "",
"showapi_res_body": {
"cityInfo": {
"c6": "yunnan",
"c5": "丽江",
"c4": "lijiang",
"c3": "丽江",
"c9": "中国",
"c8": "china",
"c7": "云南",
"c17": "+8",
"c16": "AZ9888",
"c1": "101291401",
"c2": "lijiang",
"c11": "0888",
"longitude": 100.222,
"c10": "2",
"latitude": 26.903,
"c12": "674100",
"c15": "2394"
},
"now": {
"aqi": "71",
"aqiDetail": {
"aqi": "71",
"area": "北京",
"area_code": "beijing",
"co": "0.817",
"no2": "52",
"o3": "33",
"o3_8h": "9",
"pm10": "56",
"pm2_5": "51",
"primary_pollutant": "颗粒物(PM2.5)",
"quality": "良",
"so2": "3"
},
"sd": "70%",
"temperature": "15",
"temperature_time": "18:30",
"weather": "晴",
"weather_pic": "http://appimg.showapi.com/images/weather/icon/day/00.png",
"wind_direction": "北风",
"wind_power": "1级"
},
"f1": {
"air_press": "1008 hPa",
"day": "20151023",
"day_air_temperature": "18",
"day_weather": "晴",
"day_weather_pic": "http://app1.showapi.com/weather/icon/day/00.png",
"day_wind_direction": "无持续风向",
"day_wind_power": "微风<10m/h",
"jiangshui": "3%",
"night_air_temperature": "9",
"night_weather": "晴",
"night_weather_pic": "http://app1.showapi.com/weather/icon/night/00.png",
"night_wind_direction": "无持续风向",
"night_wind_power": "微风<10m/h",
"sun_begin_end": "06:35|17:23",
"weekday": 5,
"ziwaixian": "中等",
"index": {
"yh": {
"title": "较不适宜",
"desc": "建议尽量不要去室外约会。"
},
"ls": {
},
"clothes": {
},
"dy": {
},
"beauty": {
},
"xq": {
},
"travel": {
},
"hc": {
},
"zs": {
},
"cold": {
},
"gj": {
},
"uv": {
},
"cl": {
},
"glass": {
},
"wash_car": {
},
"aqi": {
},
"ac": {
},
"mf": {
},
"ag": {
},
"pj": {
},
"nl": {
},
"pk": {
}
},
"alarmList": [{
"city": "大连",
"issueContent": "大风蓝色预警:预计23日23时到24日08时:大连、锦州、营口、盘锦、葫芦岛地区陆地偏北风6级,阵风7级;渤海、渤海海峡、黄海北部偏北风7级,阵风8级。大连、丹东、锦州、营口、盘锦、葫芦岛附近海域和航线将受影响,请注意防范。省气象灾害预警中心10月23日16时35分发布",
"issueTime": "2015-10-23 16:40:00",
"province": "辽宁省",
"signalLevel": "蓝色",
"signalType": "大风"
}],
"3hourForcast": [{
"hour": "20时-23时 ",
"temperature": "12℃/10℃",
"weather": "晴",
"weather_pic": "http://app1.showapi.com/weather/icon/night/00.png",
"wind_direction": "无持续风向",
"wind_power": "微风"
}
]
},
"hourDataList": [
{
"aqi": "53",
"aqiDetail": {
"num": "12",
"co": "0.3",
"area": "北京",
"so2": "3",
"o3": "52",
"no2": "16",
"aqi": "32",
"quality": "优质",
"pm10": "15",
"pm2_5": "6",
"o3_8h": "62",
"primary_pollutant": ""
},
"sd": "85%",
"temperature": "9",
"temperature_time": "00:00",
"weather": "多云",
"weather_pic": "http://appimg.showapi.com/images/weather/icon/night/01.png",
"wind_direction": "北风",
"wind_power": "1级"
}
],
"ret_code": 0,
"time": "20151023180000"
}
}
失败返回示例
{
"showapi_res_error": "",
"showapi_res_code": 0,
"showapi_res_id": "5fc862f58d57baa548089975",
"showapi_res_body": {
"ret_code": -1,
"remark": "请输入正确的areaCode!",
"showapi_fee_code": -1
}
}
错误码定义