<?php
$username = "";
$password = "";
$url = "https://wordpress.com/wp-login.php";
$cookie = dirname(__FILE__)."/cookie.txt";
$postdata = "log=".$username."&pwd=".$password."&rememberme=forever&wp-submit=Log+In&redirect_to=https%3A%2F%2Fwordpress.com%2F&testcookie=1
";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, "https://wordpress.com/wp-login.php?redirect_to=https%3A%2F%2Fwordpress.com%2F");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
if(!$result) {
echo "erro".curl_error($ch);
}
if($result) {
{
curl_setopt($ch, CURLOPT_POST, 1); // change back to GET
curl_setopt($ch, CURLOPT_URL, 'https://wordpress.com/me'); // set url for next request
$exec = curl_exec($ch); // make request to buy on the same handle with the current login session
}
}
curl_close($ch);
unset($ch);
?>
我想后,我成功登录卷曲脚本(https://wordpress.com/me)将被重定向到一个新的URL。在本地主机上运行代码后,屏幕上什么都没有。还我不能够在浏览器中查看什么,但饼干被插入到cookie.txt文件如何重定向后,我洛卷曲脚本