Hello,
Je développe un script PHP pour ma caméra netatmo.
J’avance bien, j’arrive à générer un token d’authentification et à récupérer le JSON qui m’intéresse via leur API.
En web, pas de soucis, l’URL https://api.netatmo.net/api/gethomedata&access_token=xxxxxxxxxxxx me remonte bien le JSON.
En PHP, la réponse de cette URL est polluée de logs SNMP :
Résultat de la commande : MIB search path: $HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp Cannot find module (SNMPv2-MIB): At line 1 in (none) Cannot find module (IF-MIB): At line 1 in (none) Cannot find module (IP-MIB): At line 1 in (none) Cannot find module (TCP-MIB): At line 1 in (none) Cannot find module (UDP-MIB): At line 1 in (none) Cannot find module (HOST-RESOURCES-MIB): At line 1 in (none) Cannot find module (NOTIFICATION-LOG-MIB): At line 1 in (none) Cannot find module (DISMAN-EVENT-MIB)
Il y en as des pages et des pages, puis mes données (JSON) suivent. Du coup, la commande json_decode se plante et mon script n’abouti à rien.
PHP cherche à charger des modules SNMP, qui ne m’intéressent pas.
J’ai essayé de désactiver les plugin monitoring au cas où, sans résultats.
Comment contourner ce problème ?
Le script :
// récuperation des datas JSON
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.netatmo.net/api/gethomedata?access_token=xxxxxxx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
// décodage JSON
$obj = json_decode($output, true);
//Export valeur voulue
$test = $obj['body']['homes']['cameras']['name'];
//Affichage valeur
echo $output;
Merci pour l’aide !
Fab