测试使用file_get_contents来访问 https 网站。 "; echo $post_data; $header = "Referer:https://www.baidu.com\r\n" ."User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0\r\n" ."Cookie: ".$cookie."\r\n" ."Conte
"; echo $post_data; $header = "Referer:https://www.baidu.com\r\n" ."User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0\r\n" ."Cookie: ".$cookie."\r\n" ."Content-type: application/x-www-form-urlencoded;charset=UTF-8\r\n"; $options = array( 'http' => array( 'method' => "POST", 'header' => $header, 'content' => $post_data, 'timeout' => 15 // 超时时间(单位:s) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); echo $result; var_dump($http_response_header) ; } } $http = new HttpsUtil(); $http->testPost(); ?>