private function http_post($url,$post,$timeout){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $post); curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); $errMsg= curl_multi_getcontent($curl); curl_close($curl); if($code != 200) { $arrRet = array( 'code' => 1, 'err_msg' => $code, 'data' => $errMsg, ); return $arrRet; } $arrRet = array( 'code' => 0, 'err_msg' => $code, 'data' => json_decode($output,true), ); return $arrRet; }
$ret = self::http_post('url', $arrInput, 2);