I'm not a programmer, and i need your help please.
I have a cURL function that returns a server response - either success or error:
400 - Error Response:
<?xml version="1.0" encoding="UTF-8"?><statusCode>400</statusCode>
<errorMessage>In order to be contacted, please enter a valid phone number.</errorMessage>
200 - Success Response:
<?xml version="1.0" encoding="UTF-8"?>
<statusCode>200</statusCode>
I need to validate response based on 200 or 400 StatusCode.
If status is 200, proceed as normal.
If status is 400 (error) then I need to eztract the error messag (strip out all tags) and ECHO error message only (in the example above - In order to be contacted, please enter a valid phone number.)
How do I do it? Please help.
Thank you.
CURL Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$resultis string even when status is 400 ?$resultsis just a raw server response - I need to parse this raw data