Hello i want to read a json data in php. I created my services but there is a problem here my expected string doesn't shown in my web page. Then i create test service a bit easy than before service. Nothing changed.
Expected result is: "Session is Not Null"
Founded result is: "{"
My Services:
$service = $_GET['service'];
switch($service)
{
case "create_ktt": saveInfo(); break;
case "create_user": createUser(); break;
case "login_user": loginUser(); break;
case "logout_user": logoffUser(); break;
case "get_session": getSession(); break;
case "get_report": getReport(); break;
case "test_json":
header('Content-type: application/json');
echo json_encode('{"session_code":"1","message":"Session is Not Null"}');
break;
default:
sendError(2);
break;
}
My Read Area:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, 'http://e-trafik.esy.es/external_services.php?service=test_json');
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_FAILONERROR, 0);
$result_json = curl_exec($curl);
$decodeislemi = json_decode($result_json);
$mesaj = $decodeislemi[message];
echo $mesaj;
?>
PS: I changed my $mesaj = $decodeislemi[message]; line to $mesaj = $decodeislemi->message; nothing changed.
error_reportingenabled.)