Maison >développement back-end >tutoriel php > curl获取内容以及模拟登录有关问题
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