这是我的代码:
$username="####################";
$password="######################";
$loginUrl = 'https://accounts.craigslist.org/login/';
//init curl
$ch = curl_init();
//Set the URL to work with
curl_setopt($ch, CURLOPT_URL, $loginUrl);
// ENABLE HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);
//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, 'inputEmailHandle='.$username.'&inputPassword='.$password);
//Handle cookies for the login
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
//not to print out the results of its query.
//Instead, it will return the results as a string return value
//from curl_exec() instead of the usual true/false.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//execute the request (the login)
$store = curl_exec($ch);
//the login is now done and you can continue to get the
//protected content.
//set the URL to the protected file
curl_setopt($ch, CURLOPT_URL, 'https://accounts.craigslist.org/login/home');
//execute the request
$content = curl_exec($ch);
curl_close($ch);
它不起作用。请建议如何操作,以便在登录后可以将其重定向到主页。
任何形式的帮助和赞赏都将受到赞赏。