高手进,关于curl模拟登陆
本帖最后由 dz215136304 于 2013-04-04 10:25:43 编辑
模拟登陆织梦,版本5.7,已经去掉后台验证码,不知道为啥一直登陆不上(提示登陆成功却又跳回登陆地址)
<br />
<br />
<?php<br />
$cookie_file = tempnam('./temp','cookie');<br />
$login_url = 'http://localhost/dedecms/dede/login.php';<br />
$post_fields = 'gotopage=%2Fdedecms%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=123456&sm1=';<br />
<br />
$ch = curl_init($login_url);<br />
curl_setopt($ch, CURLOPT_HEADER, 0);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);<br />
curl_setopt($ch, CURLOPT_POST, 1);<br />
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);<br />
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);<br />
curl_exec($ch);<br />
curl_close($ch);<br />
<br />
<br />
$url='http://localhost/dedecms/dede/article_add.php?channelid=1';<br />
$ch = curl_init($url);<br />
curl_setopt($ch, CURLOPT_HEADER, 0);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);<br />
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);<br />
$contents = curl_exec($ch);<br />
<br />
<br />
curl_close($ch);<br />
?><br />
登录后复制