j'aurai besoin d'aide pour extraire une donnée dans une chaîne JSON :
Code : Tout sélectionner
{"production":[{"type":"inverters","activeCount":10,"readingTime":1558939753,"wNow":240,"whLifetime":32305}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}
voici mon code mais ca marche pas :
Code : Tout sélectionner
public function getenphase_produc_nbr_panneau() {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->getConfiguration('ip') . '/production.json');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $this->getConfiguration('user') . ":" . $this->getConfiguration('pass'));
$response = curl_exec($ch);
curl_close($ch);
$json_data = json_decode($response, true);
$this->checkAndUpdateCmd('nbpanneau', $json_data['activeCount']);
Merci pour votre aide