| Странная ситуация, отправляю пост со всеми данными, но получаю в заголовке редирект на индекс сайта.
/*
Код взят из заголовка браузера.
*/
http://my.dot.tk/registration/rename?url=softtime
GET /registration/rename?url=softtime HTTP/1.1
Host: my.dot.tk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.dot.tk/ru/index.html?lang=ru
Cookie: mydottk_languagenr=11; dottyLn=ru; wwwLn=ru; session_id=f9935a5219323ddbce7f6ff43d9193bf
// --------------------------------------------------------------
http://my.dot.tk/registration/domainselection
POST /registration/domainselection HTTP/1.1
Host: my.dot.tk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://my.dot.tk/registration/rename?url=softtime
Cookie: mydottk_languagenr=11; dottyLn=ru; wwwLn=ru; session_id=39eab229ff65d4c0eeac94091115206a
Content-Type: application/x-www-form-urlencoded
Content-Length: 21
domaintype=FreeDomain
HTTP/1.0 200 OK
Date: Mon, 21 Mar 2011 16:50:11 GMT
Server: Apache/1.3.41 (Unix) mod_perl/1.30
Content-Type: text/html; charset=UTF-8
Set-Cookie: session_id=39eab229ff65d4c0eeac94091115206a; domain=.dot.tk; path=/; expires=Mon, 21-Mar-2011 18:30:11 GMT
Connection: close
|
Моя задача получить страницу вторую. А сайт не хочет ее выводить и редиректит.
Мой код реализации пост запроса.
<?PHP
function post($url, $referer='', $post_data='', $proxy=''){ // Функция для отправки гет, пост данных. А также для работы с куки!
$cookie_file_path = "cookies.txt";
$headers = array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB6 (.NET CLR 3.5.30729)",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language: en-us,en;q=0.5",
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Keep-Alive: 115",
"Connection: keep-alive");
$ch = curl_init($url);
if ($post_data!='')
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
if($proxy != ''){
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HEADER, 1);
$content = curl_exec($ch);
return $content;
}
post("http://www.dot.tk/", "", "", "");
post("http://www.dot.tk/en/index.html?lang=en", "http://www.dot.tk/", "", "");
post("http://my.dot.tk/registration/rename?url=softtime", "http://www.dot.tk/en/index.html?lang=en", "", "");
echo post("http://my.dot.tk/registration/domainselection", "http://my.dot.tk/registration/rename?url=softtime", "domaintype=FreeDomain", "");
?>
|
запустив данный код, на среде с поддержкой (php + CURL) овтет будет таким:
HTTP/1.0 302 Found Date: Mon, 21 Mar 2011 16:55:00 GMT Server: Apache/1.3.41 (Unix) mod_perl/1.30 Location: http://www.dot.tk/ Content-Type: text/html; charset=ISO-8859-1 Content-Length: 0 Connection: close
|
Помогите пожалуйста, получить код второй страницы. В браузере ответ другой:
HTTP/1.0 200 OK
Date: Mon, 21 Mar 2011 16:50:11 GMT
Server: Apache/1.3.41 (Unix) mod_perl/1.30
Content-Type: text/html; charset=UTF-8
Set-Cookie: session_id=39eab229ff65d4c0eeac94091115206a; domain=.dot.tk; path=/; expires=Mon, 21-Mar-2011 18:30:11 GMT
Connection: close
|
| |