我编写了一个类来更轻松地使用多 cURL 请求,当我收到 404 错误或任何其他错误时,我想记录错误。我已经CURLOPT_FAILONERROR
设置为true。
我目前正在使用curl_multi_info_read()
.
这是我的代码:
$active = null;
do {
$multi_exec = curl_multi_exec($this->_multi_handle, $active);
} while ($multi_exec == CURLM_CALL_MULTI_PERFORM);
while ($active && $multi_exec == CURLM_OK) {
if (curl_multi_select($this->_multi_handle) != -1) {
do {
$multi_exec = curl_multi_exec($this->_multi_handle, $active);
$info = curl_multi_info_read($this->_multi_handle);
if ( $info['result'] != 0 ) {
$this->_errors[] = $info; // currently storing the whole array
}
} while ($multi_exec == CURLM_CALL_MULTI_PERFORM);
}
}
错误的结果是这样的数组:
Array
(
[0] => Array
(
[msg] => 1
[result] => 22 // on success this is 0
[handle] => Resource id #4 // does this help in finding the url if I have the handle ID ?
)
那么如何获取发生错误的 URL 呢?这只会给我句柄资源 ID
并提前感谢。