温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php如何使用百度天气接口

发布时间:2021-09-10 17:37:29 来源:亿速云 阅读:137 作者:chen 栏目:开发技术

本篇内容主要讲解“php如何使用百度天气接口”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“php如何使用百度天气接口”吧!

注意地区要转码的
百度ak申请地址:http://lbsyun.baidu.com/apiconsole/key

复制代码 代码如下:


<?php

$city="嘉兴";
$content = file_get_contents("http://api.map.baidu.com/telematics/v3/weather?location=%E5%98%89%E5%85%B4&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ");
print_r(json_decode($content));

复制代码 代码如下:


{
    error: 0,
    status: "success",
    date: "2014-04-18",
    results: [
        {
            currentCity: "嘉兴",
            weather_data: [
                {
                    date: "今天(周三)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
                    weather: "多云",
                    wind: "微风",
                    temperature: "23℃"
                },
                {
                    date: "明天(周四)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42920.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42921.png",
                    weather: "雷阵雨转中雨",
                    wind: "微风",
                    temperature: "29~22℃"
                },
                {
                    date: "后天(周五)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42922.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
                    weather: "阴转多云",
                    wind: "微风",
                    temperature: "31~23℃"
                },
                {
                    date: "大后天(周六)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
                    weather: "多云",
                    wind: "微风",
                    temperature: "31~24℃"
                }
            ]
        },
        {
            currentCity: "合肥市",
            weather_data: [
                {
                    date: "今天(周三)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
                    weather: "多云",
                    wind: "东风3-4级",
                    temperature: "27℃"
                },
                {
                    date: "明天(周四)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
                    weather: "多云",
                    wind: "东北风3-4级",
                    temperature: "35~27℃"
                },
                {
                    date: "后天(周五)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
                    weather: "多云",
                    wind: "南风",
                    temperature: "35~27℃"
                },
                {
                    date: "大后天(周六)",
                    dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
                    nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
                    weather: "多云",
                    wind: "东风",
                    temperature: "34~27℃"
                }
            ]
        }
    ]
}

到此,相信大家对“php如何使用百度天气接口”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI