php curl处理异常逻辑

Posted hnhycnlc888

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php curl处理异常逻辑相关的知识,希望对你有一定的参考价值。

<?php

// 处理异常逻辑
if (!curl_errno($ch)) {

    if (200 == curl_getinfo($ch, CURLINFO_HTTP_CODE)) {

        $this->response == $response;

        if (strstr($response, ‘"result":"0"‘) || strstr($response, ‘"result":0‘))
            error_log(date(‘Y-m-d H:i:s‘) . " " . $request_url . " " . urldecode($post_data) . " " . $response . " " . $str_header . PHP_EOL, 3, ‘/home/d139/logs/mcloud-adaptor/platform_api_exception.log‘);
        // elseif( APPLICATION_ENV != ‘production‘ )
        // error_log(date(‘Y-m-d H:i:s‘)." ". $request_url ." " .urldecode($post_data)." ". $response . " "  . $str_header .PHP_EOL , 3 , ‘/home/d139/logs/mcloud-adaptor/platform_api_seems_ok.log‘);
    } else
        error_log(date(‘Y-m-d H:i:s‘) . " " . $request_url . " " . urldecode($post_data) . " " . json_encode(curl_getinfo($ch)) . " " . $str_header . PHP_EOL, 3, ‘/home/d139/logs/mcloud-adaptor/platform_http_exception.log‘);
} else {
    $errorMessageCurl = curl_error($ch);
    error_log(date(‘Y-m-d H:i:s‘) . " " . $request_url . " " . urldecode($post_data) . " " . json_encode(curl_getinfo($ch)) . " " . $errorMessageCurl . " " . $str_header . PHP_EOL, 3, ‘/home/d139/logs/mcloud-adaptor/platform_http_exception.log‘);
}
?>












以上是关于php curl处理异常逻辑的主要内容,如果未能解决你的问题,请参考以下文章