<!DOCTYPE html>
<html>
<head>
<title>getMilkings</title>
<meta charset="UTF-8">
</head>
<?php

/* Asenda sobivatega*/
define('APIID','xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'); 
$stuff=   array('kood'=>12345                                                                                
                
,'farm'=>''                
                
,'algus'=>'01.01.2022'
                
,'lopp'=>'31.01.2022'
                
,'username'=>'EPJ kasutaja'            
                
,'password'=>'************'             
               
);

  
$curl curl_init();
  
curl_setopt($curlCURLOPT_URL'https://www.epj.ee/vt/piimaveised/getMilkings.php'); 
  
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  
curl_setopt($curlCURLOPT_POST1);
  
curl_setopt($curlCURLOPT_HTTPHEADER, array('Expect: '));
  
curl_setopt($curlCURLOPT_POSTFIELDS,json_encode($stuff));
  
curl_setopt($curlCURLOPT_HTTPHEADER, array(    'Content-Type: application/json','apiId: '.APIID'Accept:application/json'));
  
$result curl_exec($curl);
  
curl_close($curl);
  
  
$a json_decode($result);
  
  if (
$a->Viga){
   echo 
$a->Viga;
   return;
  }
  
  
?>
  <table border="1"><caption>Naide vastuse kasutamise kohta</caption>
  <tr><th>Inv<th>Reg<th>Kuupaev<th>Piim<th>Rasva%<th>Valgu%<th>Somra<th>Karbamiid<th>SRE
  <?php
  
for($i 0;$i 10;$i++){
   echo 
'<tr>'
   
.'<td>'.$a[$i]->INV
   
.'<td>'.$a[$i]->REG
   
.'<td>'.$a[$i]->KUUPAEV
   
.'<td>'.$a[$i]->PIIM
   
.'<td>'.$a[$i]->RVPR
   
.'<td>'.$a[$i]->VKPR
   
.'<td>'.$a[$i]->SOM_RAK
   
.'<td>'.$a[$i]->KARB
   
.'<td>'.$a[$i]->SRE
   
;
  }
 echo 
'</table>';
?>
</html>