欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

curl获取内容以及模拟登录有关问题

程序员文章站 2022-06-08 18:45:49
...
curl获取内容以及模拟登录问题

echo $cookie_file= tempnam('./tmp','cookie');
$curl_login="http://xiaoxin.duapp.com/wp-login.php";
$curl_logined="http://xiaoxin.duapp.com/index.php";
$user = "##";
$pass = "##";
$curlPost = "log=$user&pwd=$pass";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curl_login);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
$data = curl_exec($ch);
curl_close($ch);



$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curl_logined);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLCOOKIEFILE, $cookie_file);

$data = curl_exec($ch);
curl_close($ch);

?>
设置$curl_logined="http://xiaoxin.duapp.com/index.php";时无法显示
设置$curl_logined="http://xiaoxin.duapp.com/";可以正常读取
但是没能登录
警告信息
Warning: curl_setopt() [function.curl-setopt]: Invalid curl configuration option in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpcurl.php on line 25

HTTP/1.1 200 OK X-Pingback: http://xiaoxin.duapp.com/xmlrpc.php Content-Type: text/html; charset=UTF-8 Date: Sat, 08 Dec 2012 08:48:24 GMT Server: BWS/1.0 Transfer-Encoding: chunked
还请大牛指教
------解决方案--------------------
curl_setopt($ch, CURLCOOKIEFILE, $cookie_file);
=》
CURLOPT_COOKIEFILE
curl获取内容以及模拟登录有关问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频