PHP接口编程——调用第三方接口获取天气

2021-01-30 18:16

阅读:575

标签:exe   第三方   file   temp   Oday   The   ima   dir   index   

一、根据城市名/id查询天气

技术图片

二。

技术图片

三、

技术图片

四、

技术图片

实例

‘;
//转化为数组
print_r(json_decode($res,true));     

查询结果

Array
(
    [resultcode] => 200
    [reason] => 查询成功
    [result] => Array
        (
            [sk] => Array
                (
                    [temp] => 31
                    [wind_direction] => 西南风
                    [wind_strength] => 3级
                    [humidity] => 64%
                    [time] => 12:36
                )

            [today] => Array
                (
                    [temperature] => 25℃~32℃
                    [weather] => 小雨
                    [weather_id] => Array
                        (
                            [fa] => 07
                            [fb] => 07
                        )

                    [wind] => 东南风3-5级
                    [week] => 星期五
                    [city] => 杭州
                    [date_y] => 2020年06月26日
                    [dressing_index] => 炎热
                    [dressing_advice] => 天气炎热,建议着短衫、短裙、短裤、薄型T恤衫等清凉夏季服装。
                    [uv_index] => 弱
                    [comfort_index] => 
                    [wash_index] => 不宜
                    [travel_index] => 较不宜
                    [exercise_index] => 较不宜
                    [drying_index] => 
                )

            [future] => Array
                (
                    [0] => Array
                        (
                            [temperature] => 25℃~32℃
                            [weather] => 小雨
                            [weather_id] => Array
                                (
                                    [fa] => 07
                                    [fb] => 07
                                )

                            [wind] => 东南风3-5级
                            [week] => 星期五
                            [date] => 20200626
                        )

                    [1] => Array
                        (
                            [temperature] => 24℃~28℃
                            [weather] => 中雨-大雨转阴
                            [weather_id] => Array
                                (
                                    [fa] => 22
                                    [fb] => 02
                                )

                            [wind] => 西南风4-5级
                            [week] => 星期六
                            [date] => 20200627
                        )

                    [2] => Array
                        (
                            [temperature] => 25℃~30℃
                            [weather] => 阴
                            [weather_id] => Array
                                (
                                    [fa] => 02
                                    [fb] => 02
                                )

                            [wind] => 东南风3-5级
                            [week] => 星期日
                            [date] => 20200628
                        )

                    [3] => Array
                        (
                            [temperature] => 24℃~30℃
                            [weather] => 中雨-大雨转小雨
                            [weather_id] => Array
                                (
                                    [fa] => 22
                                    [fb] => 07
                                )

                            [wind] => 西南风5-6级
                            [week] => 星期一
                            [date] => 20200629
                        )

                    [4] => Array
                        (
                            [temperature] => 23℃~30℃
                            [weather] => 小雨
                            [weather_id] => Array
                                (
                                    [fa] => 07
                                    [fb] => 07
                                )

                            [wind] => 持续无风向微风
                            [week] => 星期二
                            [date] => 20200630
                        )

                    [5] => Array
                        (
                            [temperature] => 24℃~28℃
                            [weather] => 中雨-大雨转阴
                            [weather_id] => Array
                                (
                                    [fa] => 22
                                    [fb] => 02
                                )

                            [wind] => 西南风4-5级
                            [week] => 星期三
                            [date] => 20200701
                        )

                    [6] => Array
                        (
                            [temperature] => 24℃~30℃
                            [weather] => 中雨-大雨转小雨
                            [weather_id] => Array
                                (
                                    [fa] => 22
                                    [fb] => 07
                                )

                            [wind] => 西南风5-6级
                            [week] => 星期四
                            [date] => 20200702
                        )

                )

        )

    [error_code] => 0
)

PHP接口编程——调用第三方接口获取天气

标签:exe   第三方   file   temp   Oday   The   ima   dir   index   

原文地址:https://www.cnblogs.com/lpxspring/p/13194590.html


评论


亲,登录后才可以留言!