Home > Backend Development > PHP Tutorial > Baidu weather interface is very simple

Baidu weather interface is very simple

WBOY
Release: 2016-07-25 08:48:15
Original
1222 people have browsed it
Please note that the region requires transcoding
Baidu ak application address: http://lbsyun.baidu.com/apiconsole/key
  1. $city="Jiaxing";
  2. $content = file_get_contents("http://api.map.baidu.com/telematics/v3/weather?location=%E5%98%89 %E5%85%B4&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ");
  3. print_r(json_decode($content));
Copy code
  1. {
  2. error: 0,
  3. status: "success",
  4. date: "2014-04-18",
  5. results: [
  6. {
  7. currentCity: "Jiaxing",
  8. weather_data: [
  9. {
  10. date: "Today (Wednesday)",
  11. dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
  12. nightPictureUrl: "http://api.map.baidu.com/ images/weather/night/duoyun.png",
  13. weather: "Cloudy",
  14. wind: "Breeze",
  15. temperature: "23℃"
  16. },
  17. {
  18. date: "Tomorrow (Thursday)",
  19. dayPictureUrl : "http://api.map.baidu.com/images/weather/day/leizhenyu.png",
  20. nightPictureUrl: "http://api.map.baidu.com/images/weather/night/zhongyu.png ",
  21. weather: "Thunderstorm to moderate rain",
  22. wind: "Breeze",
  23. temperature: "29~22℃"
  24. },
  25. {
  26. date: "The day after tomorrow (Friday)",
  27. dayPictureUrl: "http: //api.map.baidu.com/images/weather/day/yin.png",
  28. nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
  29. weather : "Chanting to cloudy",
  30. wind: "Breeze",
  31. temperature: "31~23℃"
  32. },
  33. {
  34. date: "The day after tomorrow (Saturday)",
  35. dayPictureUrl: "http://api.map .baidu.com/images/weather/day/duoyun.png",
  36. nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
  37. weather: "Cloudy",
  38. wind: "Breeze",
  39. temperature: "31~24℃"
  40. }
  41. ]
  42. },
  43. {
  44. currentCity: "Hefei City",
  45. weather_data: [
  46. {
  47. date: "Today (Wednesday)",
  48. dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
  49. nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun. png",
  50. weather: "Cloudy",
  51. wind: "Easterly wind level 3-4",
  52. temperature: "27℃"
  53. },
  54. {
  55. date: "Tomorrow (Thursday)",
  56. dayPictureUrl: "http: //api.map.baidu.com/images/weather/day/duoyun.png",
  57. nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
  58. weather : "Cloudy",
  59. wind: "Northeast wind level 3-4",
  60. temperature: "35~27℃"
  61. },
  62. {
  63. date: "The day after tomorrow (Friday)",
  64. dayPictureUrl: "http:// api.map.baidu.com/images/weather/day/duoyun.png",
  65. nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
  66. weather: " Cloudy",
  67. wind: "south wind",
  68. temperature: "35~27℃"
  69. },
  70. {
  71. date: "The day after tomorrow (Saturday)",
  72. dayPictureUrl: "http://api.map.baidu. com/images/weather/day/duoyun.png",
  73. nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
  74. weather: "Cloudy",
  75. wind: "Dongfeng",
  76. temperature: "34~27℃"
  77. }
  78. ]
  79. }
  80. ]
  81. }
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template