Comment fonctionne openweathermap [Résolu]

Signaler
Messages postés
2476
Date d'inscription
lundi 14 mars 2011
Statut
Membre
Dernière intervention
20 avril 2021
-
Messages postés
2476
Date d'inscription
lundi 14 mars 2011
Statut
Membre
Dernière intervention
20 avril 2021
-
bonjour a tous

il ne me manquait plus que cela pour mon site
une api qui pourra indiquer les prévisions météo

je viens de découvrir openweathermap

et déjà j ai une clé et j effectue ma première requête
https://api.openweathermap.org/data/2.5/onecall?lat=50.40965313355853&lon=4.441598958007829&lang=fr&units=metric&exclude=current&appid=e30eac7

qui fonctionne a merveille

j ai donc bien les 7 jours qui s affichent sur ma php (enfin je pense que c est bien cela )
jusque la tout va bien
voici le morceau de code qui m intéresse

    [daily] => Array
        (
            [0] => stdClass Object
                (
                    [dt] => 1618570800
                    [sunrise] => 1618548368
                    [sunset] => 1618598247
                    [moonrise] => 1618555620
                    [moonset] => 1618525200
                    [moon_phase] => 0.13
                    [temp] => stdClass Object
                        (
                            [day] => 6.63
                            [min] => -0.06
                            [max] => 8.67
                            [night] => 3.32
                            [eve] => 8.53
                            [morn] => 1.3
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 3.17
                            [night] => -1.57
                            [eve] => 6.32
                            [morn] => -1.57
                        )

                    [pressure] => 1028
                    [humidity] => 60
                    [dew_point] => -0.51
                    [wind_speed] => 5.48
                    [wind_deg] => 41
                    [wind_gust] => 6.46
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 802
                                    [main] => Clouds
                                    [description] => partiellement nuageux
                                    [icon] => 03d
                                )

                        )

                    [clouds] => 33
                    [pop] => 0
                    [uvi] => 3.96
                )

            [1] => stdClass Object
                (
                    [dt] => 1618657200
                    [sunrise] => 1618634644
                    [sunset] => 1618684743
                    [moonrise] => 1618644060
                    [moonset] => 1618615560
                    [moon_phase] => 0.16
                    [temp] => stdClass Object
                        (
                            [day] => 9.95
                            [min] => 0.04
                            [max] => 12.07
                            [night] => 5.36
                            [eve] => 10.7
                            [morn] => 0.04
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 7.35
                            [night] => -3.5
                            [eve] => 9.34
                            [morn] => -3.5
                        )

                    [pressure] => 1025
                    [humidity] => 55
                    [dew_point] => 1.22
                    [wind_speed] => 5.63
                    [wind_deg] => 28
                    [wind_gust] => 6.96
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 801
                                    [main] => Clouds
                                    [description] => peu nuageux
                                    [icon] => 02d
                                )

                        )

                    [clouds] => 12
                    [pop] => 0
                    [uvi] => 3.98
                )

            [2] => stdClass Object
                (
                    [dt] => 1618743600
                    [sunrise] => 1618720922
                    [sunset] => 1618771238
                    [moonrise] => 1618733040
                    [moonset] => 1618705560
                    [moon_phase] => 0.19
                    [temp] => stdClass Object
                        (
                            [day] => 9.51
                            [min] => 5.5
                            [max] => 11.58
                            [night] => 6.42
                            [eve] => 10.08
                            [morn] => 5.5
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 7.97
                            [night] => 3.67
                            [eve] => 9.18
                            [morn] => 3.67
                        )

                    [pressure] => 1023
                    [humidity] => 71
                    [dew_point] => 4.34
                    [wind_speed] => 3.48
                    [wind_deg] => 4
                    [wind_gust] => 3.82
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 500
                                    [main] => Rain
                                    [description] => légère pluie
                                    [icon] => 10d
                                )

                        )

                    [clouds] => 100
                    [pop] => 0.52
                    [rain] => 0.77
                    [uvi] => 2.81
                )

            [3] => stdClass Object
                (
                    [dt] => 1618830000
                    [sunrise] => 1618807201
                    [sunset] => 1618857734
                    [moonrise] => 1618822680
                    [moonset] => 1618795140
                    [moon_phase] => 0.22
                    [temp] => stdClass Object
                        (
                            [day] => 12.66
                            [min] => 5.82
                            [max] => 13.45
                            [night] => 7.28
                            [eve] => 10.64
                            [morn] => 6.38
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 11.63
                            [night] => 6.38
                            [eve] => 9.82
                            [morn] => 6.38
                        )

                    [pressure] => 1018
                    [humidity] => 63
                    [dew_point] => 5.76
                    [wind_speed] => 2.06
                    [wind_deg] => 16
                    [wind_gust] => 2.17
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 500
                                    [main] => Rain
                                    [description] => légère pluie
                                    [icon] => 10d
                                )

                        )

                    [clouds] => 92
                    [pop] => 0.85
                    [rain] => 2.6
                    [uvi] => 2.98
                )

            [4] => stdClass Object
                (
                    [dt] => 1618916400
                    [sunrise] => 1618893480
                    [sunset] => 1618944230
                    [moonrise] => 1618912920
                    [moonset] => 1618884180
                    [moon_phase] => 0.25
                    [temp] => stdClass Object
                        (
                            [day] => 14.66
                            [min] => 5.33
                            [max] => 14.7
                            [night] => 8.4
                            [eve] => 11.62
                            [morn] => 6.81
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 13.64
                            [night] => 6.81
                            [eve] => 10.72
                            [morn] => 6.81
                        )

                    [pressure] => 1013
                    [humidity] => 56
                    [dew_point] => 5.85
                    [wind_speed] => 2.29
                    [wind_deg] => 256
                    [wind_gust] => 2.83
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 500
                                    [main] => Rain
                                    [description] => légère pluie
                                    [icon] => 10d
                                )

                        )

                    [clouds] => 90
                    [pop] => 0.33
                    [rain] => 0.72
                    [uvi] => 4.93
                )

            [5] => stdClass Object
                (
                    [dt] => 1619002800
                    [sunrise] => 1618979761
                    [sunset] => 1619030726
                    [moonrise] => 1619003640
                    [moonset] => 1618972680
                    [moon_phase] => 0.29
                    [temp] => stdClass Object
                        (
                            [day] => 10.33
                            [min] => 5.69
                            [max] => 10.33
                            [night] => 5.69
                            [eve] => 8.53
                            [morn] => 8.97
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 9.64
                            [night] => 8.97
                            [eve] => 5.29
                            [morn] => 8.97
                        )

                    [pressure] => 1011
                    [humidity] => 85
                    [dew_point] => 7.72
                    [wind_speed] => 6.25
                    [wind_deg] => 345
                    [wind_gust] => 11.62
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 500
                                    [main] => Rain
                                    [description] => légère pluie
                                    [icon] => 10d
                                )

                        )

                    [clouds] => 100
                    [pop] => 0.9
                    [rain] => 2.31
                    [uvi] => 5
                )

            [6] => stdClass Object
                (
                    [dt] => 1619089200
                    [sunrise] => 1619066042
                    [sunset] => 1619117222
                    [moonrise] => 1619094660
                    [moonset] => 1619060760
                    [moon_phase] => 0.32
                    [temp] => stdClass Object
                        (
                            [day] => 7.48
                            [min] => 1.17
                            [max] => 8.54
                            [night] => 2.41
                            [eve] => 5.58
                            [morn] => 2.42
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 3.69
                            [night] => -1.1
                            [eve] => 1.24
                            [morn] => -1.1
                        )

                    [pressure] => 1022
                    [humidity] => 55
                    [dew_point] => -1.04
                    [wind_speed] => 8.27
                    [wind_deg] => 323
                    [wind_gust] => 10.06
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 500
                                    [main] => Rain
                                    [description] => légère pluie
                                    [icon] => 10d
                                )

                        )

                    [clouds] => 95
                    [pop] => 0.26
                    [rain] => 0.38
                    [uvi] => 5
                )

            [7] => stdClass Object
                (
                    [dt] => 1619175600
                    [sunrise] => 1619152325
                    [sunset] => 1619203718
                    [moonrise] => 1619185920
                    [moonset] => 1619148600
                    [moon_phase] => 0.36
                    [temp] => stdClass Object
                        (
                            [day] => 8.11
                            [min] => 0.79
                            [max] => 8.64
                            [night] => 5.16
                            [eve] => 8.3
                            [morn] => 2.67
                        )

                    [feels_like] => stdClass Object
                        (
                            [day] => 5.7
                            [night] => -0.69
                            [eve] => 6.48
                            [morn] => -0.69
                        )

                    [pressure] => 1024
                    [humidity] => 69
                    [dew_point] => 2.67
                    [wind_speed] => 5.19
                    [wind_deg] => 355
                    [wind_gust] => 6.21
                    [weather] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 803
                                    [main] => Clouds
                                    [description] => nuageux
                                    [icon] => 04d
                                )

                        )

                    [clouds] => 65
                    [pop] => 0.06
                    [uvi] => 5
                )

        )

)


je suppose donc que
 [0] => stdClass Object
est le jour actuel
et que
 [1] => stdClass Object

est bien demain et ainsi de suite ?

merci de l aide

2 réponses

Messages postés
32111
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
20 avril 2021
3 409
Bonjour,

Oui ça semble bien être ça.
Mais pour en être sûr .. faut voir la documentation de cette API et/ou leur demander un complément d'infos;
Ce n'est pas développé par nous ... et n'avons pas de clé pour tester. ( et pas envie de me créer un compte )
Messages postés
32111
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
20 avril 2021
3 409
Et oui.. je confirme
c'est bien la date d'aujourd'hui
suffit de regarder la valeur de la variable dt ( dt = DateTime ) qui est au format timestamp
http://www.timestamp.fr/
Messages postés
2476
Date d'inscription
lundi 14 mars 2011
Statut
Membre
Dernière intervention
20 avril 2021
133
bonsoir Jordane
super un grand merci pour la reponse