欢迎来到 wabc.cc 官方网站!
您的位置: 首页 - 产品分类 - 全国天气预报
全国天气预报

全国天气预报

API参数 全国天气预报_获取城市天气预报查询 调用地址: http,https://jisuweather.api.bdymkt.com/weather/city 请求方式: GET 支持格式: application/json;charset=UTF-8 调用工具: 去调试 请求参数(Headers) 请求参数(Query) 请求参数(Body) 请求参数(Path) 请求示例

联系电话: 13983470003
产品详情
API参数 全国天气预报_获取城市天气预报查询 调用地址: http,https://jisuweather.api.bdymkt.com/weather/city 请求方式: GET 支持格式: 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;

// 全国天气预报_获取城市 Java示例代码
public class RequestDemo {
    public static void main(String[] args) {
        String path = "http://jisuweather.api.bdymkt.com/weather/city";
        ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.GET, 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);
          // 返回结果格式为Json字符串
          System.out.println(response.getResult());
        } catch (Exception e) {
          e.printStackTrace();
        }
    }
}
                                    

                                    点击复制代码
                                
正常返回示例
                                    {
    "status": 0,
    "msg": "ok",
    "result": [
        {
            "cityid": "1",
            "parentid": "0",
            "citycode": "101010100",
            "city": "北京"
        },
        {
            "cityid": "24",
            "parentid": "0",
            "citycode": "101020100",
            "city": "上海"
        },
        {
            "cityid": "26",
            "parentid": "0",
            "citycode": "101030100",
            "city": "天津"
        },
        {
            "cityid": "31",
            "parentid": "0",
            "citycode": "101040100",
            "city": "重庆"
        },
        {
            "cityid": "32",
            "parentid": "0",
            "citycode": "101320101",
            "city": "香港"
        }
    ]
}
                                
失败返回示例 错误码定义
标签: {}
在线客服
微信联系
客服
扫码加微信(手机同号)
电话咨询
返回顶部