百度天氣介面 非常簡單

來源:互聯網
上載者:User
注意地區要轉碼的
百度ak申請地址:http://lbsyun.baidu.com/apiconsole/key
  1. $city="嘉興";
  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));
複製代碼
  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. }
複製代碼
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.