登錄我要登錄fashiondays.ro但error.This是我的代碼 我試過很多劇本,但我似乎無法得到它的工作...PHP捲曲不能捲曲
當前腳本:
<?php
$loginUrl = 'https://www.fashiondays.ro/login_check/';
$email = 'thomanphan%40gmail.com';//demo user name
$password = '1234567890';//demo pass
$cookie_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "cookies.txt";
if (!file_exists($cookie_file))
{
$ourFileHandle = fopen($cookie_file, 'w') or die("can't open file");
fclose($ourFileHandle);
}
// make list of POST fields
$fields = array(
'_username' => urlencode($email),
'_password' => urlencode($password),
'_country_code' => urlencode('ro'),
'_remember_me' => urlencode('1')
);
$fields_string = '';
foreach ($fields as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
rtrim($fields_string, '&');
$ch = curl_init();
$headers = array(
'accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
"content-length: " . count($fields_string) //instead of 0, how could I get the
length of the body from curl?
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //set headers
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_REFERER, 'https://www.fashiondays.ro/login/');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($ch);
if ($result === false) {
die('CURL ERROR: ' . curl_error($ch));
} else {
curl_setopt($ch, CURLOPT_URL, 'http://www.fashiondays.ro/campaigns/');
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
if ($result === false) {
die('CURL ERROR: ' . curl_error($ch));
} else {
echo $result;
}
}
?>
什麼錯誤? – 2013-03-07 05:13:01
網站返回http://www.fashiondays.ro/login/並且無法登錄 – Thoman 2013-03-07 05:14:08
請勿對您的電子郵件地址進行urlencode,它將用%40替換@。 – shapeshifter 2013-03-07 05:36:10