private function Send($url, $params)
{
$post = implode('&', $params);
$request = curl_init();
$request_timeout = 20;
curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_TIMEOUT, $request_timeout);
curl_setopt($request, CURLOPT_CONNECTTIMEOUT, $request_timeout);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Connection: Close'));
curl_setopt($request, CURLOPT_POSTFIELDS, $post);
$contents = curl_exec($request);
//$this->log_debug("[MmsApi][Send] curl contents. [$contents]");
$error_code = curl_errno($request);
if(!empty($error_code))
{
$error_message = curl_error($request);
$this->mErrorCode = 302;
$this->mErrorMessage = "CURL submission failed. Server returns: [$contents][$error_message][$error_code]";
$this->log_error("[MmsApi][Send] curl failed. [$contents][$error_message][$error_code]");
}
curl_close($request);
return $contents;
}
若是出現錯誤訊息:
Failed: Error Number: 60. Reason: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
解決方法:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
另一種方法
沒有留言:
張貼留言