当前位置:Gxlcms > PHP教程 > 精通php的curl的入,有点难

精通php的curl的入,有点难

时间:2021-07-01 10:21:17 帮助过:18人阅读

精通php的curl的进,有点难
模拟登陆织梦,版本5.7,已经去掉后台验证码,不知道为啥一直登陆不上(提示登陆成功却又跳回登陆地址)




$cookie_file = tempnam('./temp','cookie');
$login_url = 'http://localhost/dedecms/dede/login.php';
$post_fields = 'gotopage=%2Fdedecms%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=123456&sm1=';

$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);


$url='http://localhost/dedecms/dede/article_add.php?channelid=1';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);


curl_close($ch);
?>




登陆成功后要跳转到 http://localhost/dedecms/dede/article_add.php?channelid=1

分享到:


------解决方案--------------------
dede的登陆类做了限制

人气教程排行