PHP: <? function get($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208'); curl_setopt($ch, CURLOPT_COOKIE, "__utma=; __utmb=; __utmc=;__utmz=;"); $ss=curl_exec($ch); curl_close($ch); return $ss; } $a=get('http://www.rambler.ru'); echo $a; ?> про пост тут почитай: http://blog.mypapit.net/2006/02/sending-http-post-with-php-curl.html
barnaki, состряпать своими руками HTTP-запрос к веб-серверу методом GET или POST, и отправить через сокеты.
Воспользуйся моим кодом... PHP: <?php define("HTTP_GET", 0x0001); define("HTTP_POST", 0x0002); define("HTTP_HEAD", 0x0003); define("HTTP_PUT", 0x0004); define("HTTP_DELETE", 0x0006); define("HTTP_TRACE", 0x0007); define("HTTP_OPTIONS", 0x0008); define("HTTP_PROPFIND", 0x0009); define("HTTP_10", 0x0001); define("HTTP_11", 0x0002); if (!function_exists("curl_setopt_array")) { function curl_setopt_array (&$curlHandler, $curlOptions) { if (!is_array($curlOptions)) return false; foreach ($curlOptions as $option => $value) { if (!curl_setopt($curlHandler, $option, $value)) return false; } return true; } } function httpRequest ($requestMethod, $requestVersion, $requestUrl, $requestHeaders, $requestBody, $requestTimeout, $requestProxy, &$responseCode = null, &$responseHeaders = null, &$responseBody = null, &$errCode = null, &$errString = null) { if (!is_integer($requestTimeout)) return ($responseCode = $responseHeaders = $responseContent = false); $urlData = parse_url($requestUrl); if (!isset($urlData["host"])) return ($responseCode = $responseHeaders = $responseContent = false); if (!isset($urlData["scheme"])) $urlData["scheme"] = "http"; if (!isset($urlData["path"])) $urlData["path"] = "/"; if (!isset($urlData["port"]) && $urlData["scheme"] == "http") $urlData["port"] = 80; if (!isset($urlData["port"]) && $urlData["scheme"] == "https") $urlData["port"] = 443; switch ($requestMethod) { case HTTP_GET : $httpMethod = "GET"; break; case HTTP_POST : $httpMethod = "POST"; break; case HTTP_HEAD : $httpMethod = "HEAD"; break; case HTTP_PUT : $httpMethod = "PUT"; break; case HTTP_DELETE : $httpMethod = "DELETE"; break; case HTTP_TRACE : $httpMethod = "TRACE"; break; case HTTP_OPTIONS : $httpMethod = "OPTIONS"; break; case HTTP_PROPFIND : $httpMethod = "PROPFIND"; break; default : return ($responseCode = $responseHeaders = $responseContent = false); break; } switch ($requestVersion) { case HTTP_10 : $httpVersion = "1.0"; break; case HTTP_11 : $httpVersion = "1.1"; break; default : return ($responseCode = $responseHeaders = $responseContent = false); break; } if (isset($urlData["query"])) $customRequest = sprintf("%s %s?%s HTTP/%s\r\n", $httpMethod, $urlData["path"], $urlData["query"], $httpVersion); else $customRequest = sprintf("%s %s HTTP/%s\r\n", $httpMethod, $urlData["path"], $httpVersion); $customRequest .= sprintf("Host: %s\r\n", $urlData["host"]); foreach ($requestHeaders as $header) $customRequest .= sprintf("%s\r\n", $header); if ($requestMethod == HTTP_POST || $requestMethod == HTTP_PUT) if (strlen($requestBody) > 0) $customRequest .= sprintf("Content-Length: %s\r\n", strlen($requestBody)); else return ($responseCode = $responseHeaders = $responseContent = false); if (isset($urlData["user"]) && isset($urlData["pass"])) { $authValue = sprintf("%s:%s", $urlData["user"], $urlData["pass"]); $customRequest .= sprintf("Authorization: Basic %s\r\n", base64_encode($authValue)); } $customRequest .= sprintf("Connection: close\r\n", $urlData["host"]); $customRequest .= "\r\n"; if ($requestMethod == HTTP_POST || $requestMethod == HTTP_PUT) if (strlen($requestBody) > 0) $customRequest .= sprintf("%s", $requestBody); else return ($responseCode = $responseHeaders = $responseContent = false); $curlHandler = curl_init(); $curlOptions = array ( CURLOPT_URL => sprintf("%s://%s", $urlData["scheme"], $urlData["host"]), CURLOPT_PORT => $urlData["port"], CURLOPT_TIMEOUT => $requestTimeout, CURLOPT_CUSTOMREQUEST => $customRequest, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => false, CURLOPT_VERBOSE => false, CURLOPT_NOPROGRESS => true ); if ($urlData["scheme"] == "https") { $curlOptions[CURLOPT_SSL_VERIFYPEER] = false; $curlOptions[CURLOPT_SSL_VERIFYHOST] = false; } if ($requestMethod == HTTP_HEAD || $requestMethod == HTTP_OPTIONS || $requestMethod == HTTP_DELETE) $curlOptions[CURLOPT_NOBODY] = true; else $curlOptions[CURLOPT_NOBODY] = false; if (!is_null($requestProxy)) { $proxyData = parse_url("http://" . $requestProxy); if (isset($proxyData["user"]) && isset($proxyData["pass"])) $curlOptions[CURLOPT_PROXYUSERPWD] = sprintf("%s:%s", $proxyData["user"], $proxyData["pass"]); if (!isset($proxyData["host"])) return ($responseCode = $responseHeaders = $responseContent = false); $curlOptions[CURLOPT_PROXY] = $proxyData["host"]; } $result = curl_setopt_array($curlHandler, $curlOptions); if (!$result) return ($responseCode = $responseHeaders = $responseContent = false); $response = curl_exec($curlHandler); $errCode = curl_errno($curlHandler); $errString = sprintf("Error: %s", curl_error($curlHandler)); if (curl_errno($curlHandler) != CURLE_OK) { $responseCode = false; $responseHeaders = false; $responseContent = false; curl_close($curlHandler); return false; } curl_close($curlHandler); list($headers, $responseBody) = preg_split("/\r\n\r\n/", $response, 2); $headers = preg_split("/\r\n/", $headers); list(,$responseCode,) = sscanf(array_shift($headers), "%s %d %s"); $responseHeaders = $headers; return true; } ?>
Сокеты юзать можно так: PHP: function LoadPage($host,$port,$head) { $sock=@fsockopen($host,$port,$errno,$errstr,3); if (!$sock) { return false; } fwrite($sock,$head); $ret=''; while (!feof($sock)) { $ret.=fread($sock,8192) or last; } fclose($sock); return $ret; } Функции даешь хост куда подрубаться, порт, и HTTP запрос. И она возвращает данные которые вернул сервер или false cnhjbm запрос можешь типа так: PHP: function BuildHeader($method,$page,$host,$ref,$cookie,$data) { $ret="{$method} /{$page} HTTP/1.0\r\n". "Host: {$host}\r\n". "Referer: {$ref}\r\n"; if (!empty($cookie)>0) { $ret.="Cookie: {$cookie}\r\n"; } if ($method=='POST') { $ret.="Content-Length: ".strlen($data)."\r\n". "Content-Type: application/x-www-form-urlencoded\r\n\r\n{$data}\r\n"; } else $ret.="\r\n"; return $ret; } Пример использования PHP: $data="success_url=&fail_url=&try_to_login=1&email={$email}&pass={$pass}"; $head=BuildHeader('POST','login.php','vkontakte.ru','http://vkontakte.ru/login.php','',$data); $page=LoadPage('vkontakte.ru',80,$head); if ($page) { чтото делаешь тут }
2 DIAgen эта возможность вроде появилась тока в 5 php, так что на 4 PHP может не прокатить, хотя щас уже 5 везде )