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中文乱码问题的解决方法
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程