I want to make a POST request to get schedule of a train number from this page: http://www.indianrail.gov.in/train_Schedule.html
I'm using this code but it is NOT working. The resulting error shown in attachment below. What could be the problem?
PS: I've got the cgi path and arguments as in $data using Firebug
$data = array('lccp_trnname' => '14553', 'getIt' => 'Get Schedule');
$ch = curl_init();
$useragent= "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); // set user agent
curl_setopt($ch, CURLOPT_URL, 'http://www.indianrail.gov.in/cgi_bin/inet_trnnum_cgi.cgi');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$txResult = curl_exec($ch);
print "$txResult
";
:
See Question&Answers more detail:os