PHP - cURL在POST请求中返回空响应?

时间:2015-03-30 20:54:02

标签: php curl

无法弄清楚这个简单的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;

0 个答案:

没有答案