可能重复:
curl 进行身份验证但没有返回网页
我编写了这样的代码来从 curl 的结果中获取返回的 html 数据,但我没有这样做。我的代码有问题吗?
我的代码:
<?php
/* STEP 1. let’s create a cookie file */
$ckfile = tempnam ("tmp", "CURLCOOKIE");
/* STEP 2. visit the homepage to set the cookie properly */
$ch = curl_init ("http://www.batavia-air.com/");
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
/* STEP 3. visit cookiepage.php */
$ch = curl_init ("http://www.batavia-air.com/public/etiket/includes/class/booking/template/cariBookAjaxPros2.php");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
/* here you can do whatever you want with $output */
$datatopost = array (
"ajax_type" => "non_ajax",
"blnthnBerangkatPergi" => "12/12",
"jmlInfant" => "0",
"jmlPenumpang" => "1",
"kalenderPergi" => "",
"page" => "booking",
"page" => "booking",
"radio" => "flight",
"ruteBerangkat" => "CGK",
"ruteKembali" => "kembali",
"ruteTujuan" => "AMQ",
"tglBerangkatPergi" => "22",
);
$ch = curl_init ($output);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
returndata = curl_exec ($ch);
echo $returndata;
?>
或者对于网站不需要使用cookies?请帮忙..谢谢