您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

curl模拟登陆不成功

2025/8/9 3:23:16发布27次查看
curl真蛋疼老是遇到问题- -
$cookie_file=dirname(__file__).'/cookie.txt';
$data='username=账户&password=密码';
$curlobj=curl_init('http://passport.sundns.com/index.php?client_id=sundns');
curl_setopt($curlobj, curlopt_returntransfer,1);
curl_setopt($curlobj, curlopt_post,1);
curl_setopt($curlobj, curlopt_postfields,$data);
curl_setopt($curlobj, curlopt_cookiejar,$cookie_file);
$first=curl_exec($curlobj);
curl_close($curlobj);
$curlobj=curl_init('http://www.sundns.com/member.php');
curl_setopt($curlobj, curlopt_returntransfer,1);
curl_setopt($curlobj, curlopt_cookiefile,$cookie_file);
$output=curl_exec($curlobj);
curl_close($curlobj);
echo $output;
目录下的cookie.txt:
# netscape http cookie file
# http://curl.haxx.se/docs/http-cookies.html
# this file was generated by libcurl! edit at your own risk.
#httponly_passport.sundns.com false / false 0 phpsessid odjcjs622gmhg5k9b2hu92m047
mysql报错:
not found
the requested url /test/login.php was not found on this server.
是想跳到个人页面的却报了错,为什么啊
回复讨论(解决方案) 换了种写法,还是不成功
$curl = curl_init();
$cookie_jar = tempnam('d:/wamp/www/test','cookie');
curl_setopt($curl, curlopt_url,'http://www.nidebook.com/do/login.php');//登陆界面
curl_setopt($curl, curlopt_post, 1);
$request = 'username=用户名&password=密码';
curl_setopt($curl, curlopt_postfields, $request);
curl_setopt($curl, curlopt_cookiejar, $cookie_jar);
curl_setopt($curl, curlopt_returntransfer, 1);
curl_setopt($curl, curlopt_header, false);
curl_exec($curl);
curl_close($curl);
$curl2 = curl_init();
curl_setopt($curl2, curlopt_url, 'http://www.nidebook.com/member/homepage.php');//个人中心
curl_setopt($curl2, curlopt_header, false);
curl_setopt($curl2, curlopt_returntransfer, 1);
curl_setopt($curl2, curlopt_cookiefile, $cookie_jar);
$content = curl_exec($curl2);
echo $content;
执行后还是用户登陆界面,显示用户不存在,怀疑是cookie有问题
cookie里的数据:
# netscape http cookie file
# http://curl.haxx.se/docs/http-cookies.html
# this file was generated by libcurl! edit at your own risk.
www.nidebook.com false / false 1461245580 usr eauxwntm%090%091461159180%09http%3a%2f%2fwww.nidebook.com%2fdo%2flogin.php
将form 的一些hidden值也带过去
将form 的一些hidden值也带过去
原来是这样,谢谢了,没人教碰到问题真是两眼一抹黑
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product