I am using curl to ask
when the error is 500, for example,
how can I catch the information he spits out here with me?
because if there are no errors, the counterpart can send me a reply to json and receive it, it can show
, but it will send back 500 errors when the counterpart goes wrong, so how can I catch this piece of text?
I"ve been doing this for a long time, but I still haven"t caught
$ch = curl_init($api);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);