1. 程式人生 > >php curl處理異常邏輯

php curl處理異常邏輯

head exc platform date clas ssa esp get ||

<?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處理異常邏輯