Добрый день!
Провайдер услуги отдает нам ошибку в виде кастомного серверного заголовка:
Цитата |
RequestUrl: http:/blablabla:/vice/authorize?login=567565 Date: Wed, 24 Aug 2016 06:28:48 GMT errcode: 1 Server: nginx/1.8.1 Connection: keep-alive Transfer-Encoding: chunked 401 Unauthorized |
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); //200,401,404 и тд
$transfer = curl_getinfo($ch);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
list($headers, $content) = explode("\r\n\r\n", $res, 2);
$error = null;
if (preg_match('#^errcode:\s*(.*)$#mi', $headers, $m)) {
$error = $m[1];
}
echo "Error: $error<br>";