• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php使用百度天气接口示例_php实例

php 搞代码 4年前 (2022-01-26) 44次浏览 已收录 0个评论

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

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

{<BR>    error: 0,<BR>    status: "success",<BR>    date: "2014-04-18",<BR>    results: [<BR>        {<BR>            currentCity: "嘉兴",<BR>            weather_data: [<BR>                {<BR>                    date: "今天(周三)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",<BR>                    weather: "多云",<BR>                    wind: "微风",<BR>                    temperature: "23℃"<BR>                },<BR>                {<BR>                    date: "明天(周四)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/leizhenyu.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/zhongyu.png",<BR>                    weather: "雷阵雨转中雨",<BR>                    wind: "微风",<BR>                    temperature: "29~22℃"<BR>                },<BR>                {<BR>                    date: "后天(周五)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/yin.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",<BR>                    weather: "阴转多云",<BR>                    wind: "微风",<BR>                    temperature: "31~23℃"<BR>                },<BR>                {<BR>                    date: "大后天(周六)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",<BR>                    weather: "多云",<BR>                    wind: "微风",<BR>                    temperature: "31~24℃"<BR>                }<BR>            ]<BR>        },<BR>        {<BR>            currentCity: "合肥市",<BR>            weather_data: [<BR>                {<BR>                    date: "今天(周三)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",<BR>                    weather: "多云",<BR>                    wind: "东风3-4级",<BR>                    temperature: "27℃"<BR>                },<BR>                {<BR>                    date: "明天(周四)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",<BR>                    weather: "多云",<BR>                    wind: "东北风3-4级",<BR>                    temperature: "35~27℃"<BR>                },<BR>                {<BR>                    date: "后天(周五)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",<BR>                    weather: "多云",<BR>                    wind: "南风",<BR>                    temperature: "35~27℃"<BR>                },<BR>                {<BR>                    date: "大后天(周六)",<BR>                    dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",<BR>                    nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",<BR>                    weather: "多云",<BR>                    wind: "东风",<BR>                    temperature: "34~27℃"<BR>                }<BR>        <strong>+本文来源gao@daima#com搞(%代@#码网</strong><pre>搞代gaodaima码

]
}
]
}


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php使用百度天气接口示例_php实例
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址