php使用百度天气接口示例
网络编程 2021-07-05 09:49www.168986.cn编程入门
这篇文章主要介绍了百度天气接口使用示例,需要的朋友可以参考下
注意地区要转码的
百度ak申请地址http://lbsyun.baidu./apiconsole/key
代码如下:
<?php
$city="嘉兴";
$content = file_get_contents("http://api.map.baidu./telematics/v3/weather?location=%E5%98%89%E5%85%B4&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ");
print_r(json_decode($content));
代码如下:
{
error: 0,
status: "suess",
date: "2014-04-18",
results: [
{
currentCity: "嘉兴",
weather_data: [
{
date: "今天(周三)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/duoyun.png",
weather: "多云",
wind: "微风",
temperature: "23℃"
},
{
date: "明天(周四)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/leizhenyu.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/zhongyu.png",
weather: "雷阵雨转中雨",
wind: "微风",
temperature: "29~22℃"
},
{
date: "后天(周五)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/yin.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/duoyun.png",
weather: "阴转多云",
wind: "微风",
temperature: "31~23℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/duoyun.png",
weather: "多云",
wind: "微风",
temperature: "31~24℃"
}
]
},
{
currentCity: "合肥市",
weather_data: [
{
date: "今天(周三)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/duoyun.png",
weather: "多云",
wind: "东风3-4级",
temperature: "27℃"
},
{
date: "明天(周四)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/duoyun.png",
weather: "多云",
wind: "东北风3-4级",
temperature: "35~27℃"
},
{
date: "后天(周五)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/duoyun.png",
weather: "多云",
wind: "南风",
temperature: "35~27℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "http://api.map.baidu./images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu./images/weather/night/duoyun.png",
weather: "多云",
wind: "东风",
temperature: "34~27℃"
}
]
}
]
}
上一篇:php cli换行示例
下一篇:phpmailer中文乱码问题的解决方法
编程语言
- 宿迁百度关键词排名指南:实现精准营销的关键
- 四川SEO优化怎么做网络推广
- 立昂技术备案老域名收购:如何为您的业务赋能
- 安徽百度关键词seo贵不贵,一般需要多少钱
- 吉林百度快照排名怎么做电话营销
- 多伦新手做SEO怎么做
- 甘肃优化关键词排名推广怎么做论坛营销
- 沙雅SEO网站推广:提升您的在线可见性
- 四川SEO优化如何提升销售额和销售量
- 聂荣网站排名优化:提升网站可见性的全方位指
- 涞水SEO:提升地方企业在线可见性的策略
- 辽宁百度seo排名怎样做网站排名
- 临湘哪有关键词排名优化:提升网站可见度的关
- 黑龙江百度网站优化有没有优惠
- 凉城优化关键词排名推广:提升您的网络可见性
- 萝北整站优化:提升您网站流量和排名的全面指