<?php
$cara=$_GET["cara"];
$manguera=$_GET["manguera"];

$url = "https://192.168.16.200/jsonPTS";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($curl, CURLOPT_USERPWD, "jpanta:gigi240602");
//curl_setopt($curl, CURLOPT_USERPWD,"admin:Infosol24");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "Accept: application/json",
//   "Authorization: Basic YWRtaW46YWRtaW4=",
   "Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = <<<DATA
{
 "Protocol":"jsonPTS",
 "Packets":[{
 "Id":1,
 "Type":"PumpGetTotals",
 "Data":{
      "Pump":$cara,
      "Nozzle":$manguera
    }
}]
}
DATA;
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$resp=curl_exec($curl);

curl_close($curl);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($curl, CURLOPT_USERPWD, "jpanta:gigi240602");
//curl_setopt($curl, CURLOPT_USERPWD, "admin:Infosol24");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$data =  <<<DATA
{
  "Protocol":"jsonPTS",
  "Packets":[{
    "Id":1,
    "Type":"PumpGetStatus",
    "Data":{
      "Pump":$cara
    }
  }]
}
DATA;
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$resp=curl_exec($curl);
$respuesta=json_decode($resp,true);
curl_close($curl);

//for debug only!
echo $resp;
?>
