I need help in connecting with the JSON using PHP


#1

I am connecting PHP using my wamp server.

Unable to connect to JSON. the details as follows

Details given from IOT (Datonis)
curl -X GET -H “Content-Type:application/json” -H “X-Auth-Token:olezAZXGQn9MutnfNerKDQ” -d ‘{“thing_template_key”:“af31ae5fb2”}’ https://api.datonis.io/api/v3/metrics

I tried the following code but unable to get any result:

<?php $token = "d7d28ad3tfe81a5tf2382c2f81573ec255bc487d"; $key = "6f2159f998"; $url = "https://api.datonis.io/api/v3/metrics"; $headers = array(); $headers[] = "thing_template_key:$key"; $headers[] = "x-auth-token:$token"; $headers[] = 'Content-Type:application/json'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"url"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); $arr_response = json_decode($response, true); print_r($arr_response); ?>