首頁 > 後端開發 > php教程 > 百度天氣介面 非常簡單

百度天氣介面 非常簡單

WBOY
發布: 2016-07-25 08:48:15
原創
1199 人瀏覽過
>複製程式碼
注意地區要轉碼的
百度ak申請網址:http://lbsyun.baidu.com/apiconsole/key
  1. $city="嘉興";
  2. $content = file_get_contents("http://api.map.baidu.com/telematics /v3/weather?location=嘉興&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ");
  3. print_r(json_decode($content));
複製程式碼
  1. {
  2. error: 0,
  3. status: "success",
  4. date: "2014-04-18",
  5. results: [
  6. {
  7. currentCity: "嘉興",
  8. weather_data: [
  9. {
  10. date: "今天(週三)",
  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: "多雲",
  14. wind: "微風",
  15. temperature: "23℃"
  16. },
  17. {
  18. date: "明天(週四)",
  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: "雷陣雨轉中雨",
  22. wind: "微風",
  23. temperature: "29~22℃"
  24. },
  25. {
  26. date: "後天(週五) ",
  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: "陰轉多雲",
  30. wind: "微風",
  31. temperature: "31~23℃"
  32. },
  33. {
  34. date: "大後天(週六)",
  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: "多雲",
  38. wind: "微風",
  39. temperature: "31~24℃"
  40. }
  41. ]
  42. },
  43. {
  44. currentCity: "合肥市",
  45. weather_data: [
  46. {
  47. date: "今天(週三)",
  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: "多雲",
  51. wind: "東風3-4級",
  52. temperature: "27℃"
  53. },
  54. {
  55. date: "明天(週四)",
  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: "多雲",
  59. wind: "東北風3-4級",
  60. temperature: "35~27 ℃"
  61. },
  62. {
  63. date: "後天(週五)",
  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: "多雲",
  67. wind: "南風" ,
  68. temperature: "35~27℃"
  69. },
  70. {
  71. date: "大後天(週六)",
  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: "多雲" ,
  75. wind: "東風",
  76. temperature: "34~27℃"
  77. }
  78. ]
  79. }
  80. ]
  81. }
} ]}


來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板