I wanted to circumvent the errors I might encounter in php curl with try / catch, but the cath part does not work, where is the problem ??
<?php
try {
$username = $_POST['username'];
$pass = $_POST['pass'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://example.com/api?username=".$username."&password=".$pass);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
$json = json_decode($server_output, true);
$token = $json["session"]["sessionId"];
echo $token;
curl_close ($ch);
}
catch(Exception $e){
echo "Error";
}
?>