0

Can't figure out what is wrong in this simple PHP cURL request. Request works fine in Postman. It is a POST request that returns html data.

$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;
XIMRX
  • 2,130
  • 3
  • 29
  • 60
  • A small convenience: you can replace the `$postData` construction loop with [`$postData = http_build_query($params)`](http://php.net/http_build_query). Also, what's the output of `curl_info($ch)` (before `curl_close`)? – xathien Mar 30 '15 at 20:59
  • thanks @xathien but that is not causing issue i guess. curl_info($ch) is nothing – XIMRX Mar 30 '15 at 21:01
  • 1
    What are the symptoms of the problem? What tells you it's not working? Again, what's the `curl_info($ch)` output? – xathien Mar 30 '15 at 21:03
  • Can you post the header & request info of your outgoing request? See http://stackoverflow.com/a/4406238/1777956 and http://stackoverflow.com/a/2138886/1777956 for how to retrieve it. – Elias Mar 30 '15 at 21:09

0 Answers0