The first parameter you're passing to fsockopen() is invalid. You need to pass a valid hostname (such as www.example.com). Take a look at the PHP Manual for some help: http://www.php.net/fsockopen
The HTTP info you're sending to the server is also incorrect. Once again you need to specify the hostname in the HTTP "Host: " header. You request the page within the hostname via the initial GET command, which you're only using to request the root directory. Another problem is that you're requesting HTTP/1.1 which means you have to handle all sorts of things including chunked encoding and a possible HTTP Continue message. You could use the cURL library and that way you could avoid all these complications of communicating via HTTP, or you could use this function I made a while back:
//attempts to collect data from a specified url, returns false on failure
function _remote($url, $g_vars = array(), $p_vars = false, $settings = array()){
if(($url_info = @parse_url($url)) !== false && isset($url_info['host'])){
//settings
$follow_redirects = isset($settings['follow_redirects']) ? (bool) $settings['follow_redirects'] : true;
$user_agent = isset($settings['user_agent']) ? $settings['user_agent'] : '';
$extra_headers = isset($settings['headers']) ? (array) $settings['headers'] : array();
$http = isset($settings['HTTP1.1']) ? ($settings['HTTP1.1'] ? 'HTTP/1.1' : 'HTTP/1.0') : 'HTTP/1.1';
$timeout = isset($settings['timeout']) ? (int) $settings['timeout'] : 10;
$one_way = isset($settings['one_way']) ? isset($settings['one_way']) : false;
$host = $url_info['host'];
$path = isset($url_info['path']) ? $url_info['path'] : '/';
$fp = @fsockopen($host, 80, $errno, $errstr, $timeout);
if($fp){
$get_vars = $g_vars;
$post_vars = $p_vars;
if(!is_array($get_vars)){
$get_vars = array();
}
foreach($get_vars as $key => $val){
$get_vars[$key] = urlencode($key) . '=' . urlencode($val);
}
$get_vars = implode('&', $get_vars);
if($get_vars != ''){
$path .= '?'.$get_vars;
}
if($post_vars !== false && is_array($post_vars)){
$out = "POST ".$path.' '.$http."\r\n";
}else{
$out = "GET ".$path.' '.$http."\r\n";
}
if($http == 'HTTP/1.1'){
$out .= 'Host: '.$host."\r\n";
}
$out .= 'User-Agent: '.$user_agent."\r\n";
foreach($extra_headers as $name => $value){
$upper = strtoupper($name);
if($upper == 'IF-MODIFIED-SINCE' || $upper == 'IF-UNMODIFIED-SINCE'){
$value = _remote_time2date($value);
}
$out .= $name.': '.trim($value)."\r\n";
}
if($post_vars !== false && is_array($post_vars)){
foreach($post_vars as $key => $val){
$post_vars[$key] = urlencode($key) . '=' . urlencode($val);
}
$post_vars = implode('&', $post_vars);
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Content-Length: ".strlen($post_vars)."\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= $post_vars."\r\n";
}else{
$out .= "Content-Length: 0\r\n";
$out .= "Connection: Close\r\n\r\n";
}
fwrite($fp, $out);
if($one_way){
fclose($fp);
return array('success' => true);
}
$fline = fgets($fp, 1024);
if(preg_match('!^HTTP/1\.(0|1)\s+([0-9]+)\s+([A-Za-z _0-9]+)$!i', trim($fline), $match) && $match[2] == '100'){
$data = '';
}else{
$data = $fline;
}
while(!feof($fp)){
$data .= fgets($fp, 128);
}
fclose($fp);
$sdata = preg_split('!(\\r\\n\\r\\n|\\n\\n)!s', $data, 2);
$hdata = $sdata[0];
$cdata = isset($sdata[1]) ? $sdata[1] : '0';
$lines = preg_split('!(\\r\\n|\\n)!s', $hdata);
$headers = array();
$main = array();
$prev = false;
foreach($lines as $line){
if(preg_match('!^HTTP/1\.(0|1)\s+([0-9]+)\s+([A-Za-z _0-9]+)$!i', trim($line), $match) && empty($main)){
$main['version'] = '1.'.$match[1];
$main['status'] = $match[2];
$main['message'] = $match[3];
if($main['status'][0] == '4' || $main['status'][0] == '5'){
$success = false;
}else{
$success = true;
}
}else{
$line = explode(':', $line, 2);
if(!isset($line[1]) && $prev !== false){
$headers[$prev] .= ' '.trim($line[0]);
continue;
}
$name = strtoupper($line[0]);
if(substr($name, 0, 3) == '---'){
continue;
}
$headers[$name] = isset($line[1]) ? trim($line[1]) : '';
$prev = $name;
}
}
if($follow_redirects &&
($main['status'] == '301' || $main['status'] == '302' || $main['status'] == '303')
&& isset($headers['LOCATION'])){
return _remote($headers['LOCATION'], $g_vars, $p_vars, $settings);
}
if(isset($headers['DATE'])){
$headers['DATE'] = _remote_date2time($headers['DATE']);
}
$cdata = ltrim($cdata);
if(isset($headers['TRANSFER-ENCODING'])){
unset($headers['TRANSFER-ENCODING']);
$content = '';
$i = 0;
while($dat = _remote_chunk($i, $cdata)){
$content .= $dat;
}
}else{
$content = $cdata;
}
return array('request' => $out, 'success' => $success, 'main' => $main, 'headers' => $headers, 'content' => trim($content));
}
}
return false;
}
function _remote_date2time($date){
$date = trim($date);
if(preg_match('!^([A-Z][a-z]{2}),\s+([0-9]{1,2})\s+([A-Z][a-z]{2})\s+([0-9]{4})\s+([0-9]{1,2}):([0-9]{2}):([0-9]{2})\s+GMT$!is', $date, $match)){
$day = $match[2];
$month = $match[3];
$months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$month = array_search($month, $months);
if($month === false){
$month = 1;
}else{
$month++;
}
$year = $match[4];
$hours = $match[5];
$mins = $match[6];
$secs = $match[7];
return gmmktime($hours, $mins, $secs, $month, $day, $year);
}
return $date;
}
function _remote_time2date($time){
return gmdate('D, j M Y G:i:s', (int) trim($time)).' GMT';
}
function _remote_chunk(&$i, $cdata){
$hex = '';
$p = false;
while($cdata[$i] == ' ' || $cdata[$i] == "\r" || $cdata[$i] == "\n" || $cdata[$i] == "\t"){
$i++;
}
while(true){
if(!isset($cdata[$i])){
return false;
}
if($p === true){
if($cdata[$i] != "\r"){
$i++;
continue;
}else{
$i += 2;
break;
}
}
if($cdata[$i] != ';' && $cdata[$i] != "\r"){
$hex .= $cdata[$i];
}else if($cdata[$i] == "\r"){
$i += 2;
break;
}else{
$p = true;
}
$i++;
}
$hex = trim($hex);
if($hex == '0'){
return false;
}
$len = sscanf($hex, "%X");
$len = $len[0];
$txt = substr($cdata, $i, $len);
$i += $len;
return $txt;
}
It's a fairly simple function, pass the url to want to retrieve in the first parameter, any values you want to transfer via GET in the second, any values you want to transfer via POST in the third and the fourth parameter allows you to specify some settings such as whether to follow redirects, what to identify the user agent as and any extra headers that you may wish to send. The function isn't perfect, so you might want to adapt it for your needs.