/** * * curl 提交数据 * * @param unknown $url * 提交的链接 * @param string $data * 如果有数据 提交类型为post * @return unknown */ protected function https_request($url, $data = null) { $curl = curl_init (); if (class_exists ( '/CURLFile' )) { // php5.5跟php5.6中的CURLOPT_SAFE_UPLOAD的默认值不同 curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, true ); } else { if (defined ( 'CURLOPT_SAFE_UPLOAD' )) { curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, false ); } } curl_setopt ( $curl, CURLOPT_URL, $url ); curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, FALSE ); if (! empty ( $data )) { curl_setopt ( $curl, CURLOPT_POST, 1 ); curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data ); } curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 ); $output = curl_exec ( $curl ); curl_close ( $curl ); return $output; }