
12.01.2008, 21:06
|
|
Познающий
Регистрация: 26.05.2007
Сообщений: 63
С нами:
9979529
Репутация:
86
|
|
Вопрос по сокетам. Нужно получить инфу лежащую на страничке, которая закрыта авторизацией.
PHP код:
$fp=fsockopen("xxxyyy.ru",80,$errno,$errstr,10);
$out = "GET /in.php?email=yyyzzz@xxx.ru&pass=12345 HTTP/1.0\r\n";
$out .= "Host: xxxyyy.ru\r\n";
$out .= "User-Agent: Firefox\r\n";
$out .= "Referer: xxxyyy.ru/login.php\r\n";
$out .= "Cookie: income=1\r\n";
$out .= "Content-Type: text/html; charset=windows-1251\r\n\r\n";
fwrite($fp,$out);
$ans='';
while(!feof($fp))
{
$ans.=fgets($fp,128);
}
авторизация пройдена...
Получаю ответ
HTTP/1.1 302 Found
Server: nginx/0.5.30
Date: Sat, 12 Jan 2008 16:51:21 GMT
Content-Type: text/html; charset=windows-1251
Connection: close
X-Powered-By: PHP/5.2.0-8+etch9
Pragma: no-cache
Cache-control: private, must-revalidate
Set-Cookie: remixchk=5; expires=Sun, 11-Jan-2009 16:51:21 GMT; path=/; domain=.xxxyyy.ru
Set-Cookie: remixchk=5; expires=Sun, 11-Jan-2009 16:51:21 GMT; path=/; domain=.xxxyyy.ru
Set-Cookie: remixmid=12345; expires=Sun, 11-Jan-2009 16:51:21 GMT; path=/; domain=.xxxyyy.ru
Set-Cookie: remixemail=yyyzzz@xxx.ru; expires=Sun, 11-Jan-2009 16:51:21 GMT; path=/; domain=.xxxyyy.ru
Set-Cookie: remixpass=fc6e3893c5802236c07a70d3da0ddef3; expires=Sun, 11-Jan-2009 16:51:21 GMT; path=/; domain=.xxxyyy.ru
Location: /index.php
Content-Length: 0
Теперь нужно получить контент
PHP код:
$out = "GET /page.php HTTP/1.0\r\n";
$out .= "Host: xxxyyy.ru\r\n";
$out .= "User-Agent: Firefox\r\n";
$out .= "Referer: xxxyyy.ru\r\n";
$out .= "Content-Type: text/html; charset=windows-1251\r\n\r\n";
fwrite($fp, $out);
$ans='';
while(!feof($fp)) {
$ans.=fgets($fp,128);
}
Получаю ответ
HTTP/1.1 302 Found
Server: nginx/0.5.30
Date: Sat, 12 Jan 2008 16:51:21 GMT
Content-Type: text/html; charset=windows-1251
Connection: close
X-Powered-By: PHP/5.1.0-8+etch9
Pragma: no-cache
Cache-control: private, must-revalidate
Set-Cookie: remixchk=5; expires=Sun, 11-Jan-2009 16:51:21 GMT; path=/; domain=.xxxyyy.ru
Location: login.php
Content-Length: 0
Вопрос : как "сохранить" авторизацию?
|
|
|