无法弄清楚这个简单的PHP cURL请求有什么问题。请求在Postman中正常工作。这是一个返回html数据的POST请求。
$params = array(
"County_ID" => "62",
"Location_ID" => "73",
"Court" => "Both",
"DocketMonth" => "3",
"DocketDay" => "30",
"DocketYear" => "2015",
"Lastname" => "",
"Firstname" => "John"
);
$url = "https://www.courts.state.co.us/dockets/index.cfm#results";
$postData = '';
foreach ($params as $k => $v) {
$postData .= $k . '=' . $v . '&';
}
rtrim($postData, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, count($postData));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$output = curl_exec($ch);
curl_close($ch);
echo $output;