i have searched a lot on google and here but im not getting any further with my problem. I am not a coder though I am trying to parse JSON to PHP Variables, but i get an empty response, where i want a table to be shown or at least any jsondata
Here is what my code looks like:
<!DOCTYPE html>
<html>
<body>
<h1>Available Agents </h1>
<?php
$url = 'https://url/livewebservice/imoscontactagentstate?Username=username&Pwd=password&Cmd=GetState&ResultType=JSON';
// Initiate curl
$ch = curl_init ($url);
$data = json_encode ($data,true);
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array (
' Content-Type: application/x-www-form-urlencoded ',
'charset=utf-8')
);
$result = curl_exec ($ch);
curl_close ($ch);
return $result;
var_dump(json_decode($result, true));
print_r($result);
foreach ($result as $key => $value)
{
echo ' <td><font face="calibri"color="red">'.$value[type].' </font></td><td><font face="calibri"color="blue">'.$value[category].' </font></td><td><font face="calibri"color="green">'.$value[amount].' </font></tr><tr>';
}
echo "</tr></table>";
?>
</body>
</html>
I am grateful for any hints