码迷,mamicode.com
首页 > Web开发 > 详细

php curl处理异常逻辑

时间:2018-09-29 00:44:22      阅读:376      评论:0      收藏:0      [点我收藏+]

标签:code   home   this   lin   enc   lse   app   log   res   

<?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‘) . "\t" . $request_url . "\t" . urldecode($post_data) . "\t" . $response . "\t" . $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‘)."\t". $request_url ."\t" .urldecode($post_data)."\t". $response . "\t"  . $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‘) . "\t" . $request_url . "\t" . urldecode($post_data) . "\t" . json_encode(curl_getinfo($ch)) . "\t" . $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‘) . "\t" . $request_url . "\t" . urldecode($post_data) . "\t" . json_encode(curl_getinfo($ch)) . "\t" . $errorMessageCurl . "\t" . $str_header . PHP_EOL, 3, ‘/home/d139/logs/mcloud-adaptor/platform_http_exception.log‘);
}
?>

php curl处理异常逻辑

标签:code   home   this   lin   enc   lse   app   log   res   

原文地址:https://www.cnblogs.com/hnhycnlc888/p/9721558.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!