onalps
中级会员
 
一般会员
UID 63212
精华
0
积分 310
帖子 228
金钱 310 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2005-2-17
状态 离线
|
curl模拟登录问题,谢谢
我想模拟登录,但总是不成功,请教高手给看看,我服务器,php4.39,libcurl/7.12.1
代码如下:
<?php
/*
#利用cookie和post用法*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://bbs.wish365.com/logging.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "action=login&username=testcurl&password=123456");
ob_start(); // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean(); // stop preventing output
curl_close ($ch);
unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "./cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://bbs.wish365.com/search.php");
$buf2 = curl_exec ($ch);
curl_close ($ch);
echo $buf2;
//echo "<PRE>".htmlentities($buf2)."</PRE>";
?>
|
|