我为这个网站创建了一个注册脚本。 我知道在注册时有验证码,但这不是问题,当我运行它时,它显示“你的会话已过期” 它似乎我有一些cookie问题。我试过tempcookie但仍然是相同的.. 我不明白这些问题是什么。 如果它显示“无效的验证码”或类似的东西,那么它的确定。但它显示Cookie问题。
这是代码。
//$cn = str_replace(".","",$_SERVER['REMOTE_ADDR']);
//$finalcookie = "coki/".$cn.".txt";
$finalcookie = tempnam("/tmp", "CURLCOOKIE");
$url="http://www.ypox.com";
$login="$url/content/login.html";
$signup="$url/content/signup.action";
$agent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $login);
curl_setopt($ch, CURLOPT_COOKIEJAR, $finalcookie);
curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate");
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, $login);
$html=curl_exec($ch);
//echo $html;
//echo '<img src=captcha.php><br>';
$name="Rahul";
$email="rahul12345@gmail.com";
$mobile="8798147385";
$cap="captcha";
$data="hidGen=Mr&tfUserName=$name&tfMobileNum=$mobile&tfUserID=$email&date1=10%2F10%2F1980&tfReferCode=&textcode=$cap&checkaccept=on";
curl_setopt($ch, CURLOPT_URL, $signup);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEJAR,$finalcookie);
curl_setopt($ch, CURLOPT_COOKIEFILE,$finalcookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_REFERER, $login);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html=curl_exec($ch);
echo $html;
答案 0 :(得分:0)
您可以使用详细输出来比较发送的卷曲与您希望发送的卷曲相比。也许没有发送cookie。打开一个文件写入流$ fp,让curl在该文件中打印出它发送和接收的全文。
/* in your setup */
$fp = fopen ( 'somefile.txt', 'w' );
/* then later in your code, only once in first group */
curl_setopt ( $ch, CURLOPT_VERBOSE, true );
curl_setopt ( $ch, CURLOPT_STDERR, $fp );