/** * php post請求 * @param [string] $url [description] * @param [array] $data [description] * @return [type] [description] */ function post2($url, $data){//file_get_content $postdata = http_build_query($data); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); return $result; } //php curl 更靈活,推薦使用