JSON Error on posting Data using PHP -


following coding have done. after posting data, getting error as:

'message' => string ''from' , 'to' date must given' (length=34).

following code:

$auth_token=$_request['auth_token']; $ch = curl_init('https://api.datonis.io/api/v3/datonis_query/thing_aggregated_data'); curl_setopt_array($ch, array( curlopt_post => true, curlopt_returntransfer => true,  curlopt_httpheader => array(         'x-auth-token:'.$auth_token,         'thing_key:6f2159f998',         'idle_time_required:true',         'from:2016/02/02 17:05:00',         'to:2016/08/29 17:10:00',         'time_zone:asia/calcutta',         'content-type:application/json', ),   )); curl_setopt($ch, curlopt_ssl_verifypeer, false);  // send request $response = curl_exec($ch);  // check errors if($response === false){     die(curl_error($ch)); }  // decode response //var_dump($response); $responsedata = json_decode($response, true);  // print date response var_dump($responsedata); 

actually want data details contained in post request data.

use "curlopt_postfields":

$data = array("from" => "2016/02/02 17:05:00", "to" => "2016/08/29 17:10:00");                                                                     $data_string = json_encode($data);                                                                                     curl_setopt($ch, curlopt_postfields, $data_string);                                                                                                                                       curl_setopt($ch, curlopt_httpheader, array(                                                                               'content-type: application/json')                                                                        

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -