$f = get('https://twitter.com/', 'https://twitter.com/', $_SERVER['HTTP_USER_AGENT'], '', true);
var_dump($f);
function get($url, $ref, $ua, $cook, $ssl)
{
$url = parse_url($url);
$line="";
$connecthost = $ssl ? 'ssl://' . $url['host'] : $url['host'];
$port = $ssl ? 443 : 80;
$fp=fsockopen($connecthost, $port, $errno, $errstr, 60);
if(!$fp) {
return $connecthost . ': ' . $errstr;
}
else
{
$query = isset($url['query']) ? '?' . $url['query'] : '';
$path = $url['path'] . $query;
$headers = "GET $path HTTP/1.1\r\n";
$headers .="Host: {$url['host']}\r\n";
$headers .="User-Agent: $ua\r\n";
$headers .= "Accept-Language: en,en-US;q=0.9,en;q=0.8\r\n";
$headers .="Cookie: $cook\r\n";
$headers .="Connection: Close\r\n";
$headers .="Referer: $ref\r\n\r\n";
fwrite($fp, $headers);
while(!feof($fp)){
$line .= fgets($fp, 1024);
}
fclose($fp);
}
return $line;
}
var_dump($f) ничего не возвращает. В error_log пусто.