php curl post请求
/** * CreateBy Song * @param String $url url地址 * @param Array $post url参数 * @return Array */ function PostCUrl($url, $post) { header("content-type:text/html;charset=utf-8"); $data = json_encode($post); $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_POST, true ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ( $ch, CURLOPT_HEADER, false ); curl_setopt ( $ch, CURLOPT_TIMEOUT, 30 ); $result = curl_exec ( $ch ); //这个是读到的值 if(curl_errno($ch)){ print_r(curl_error($ch)); } curl_close ( $ch ); unset ( $ch ); return json_decode($result,true); }