Ciao
Ti posto questo codice che ho rimediato su php.net e provato personalmente..
Sono 2 funzioni, GET e POST, diciamo che ciò che devi settare è la variabile $query e host
codice:
$useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)";
function post($host,$query,$others='') { Global $useragent;
$path=explode('/',$host);
$host=$path[0];
unset($path[0]);
$path='/'.(implode('/',$path));
$post="POST $path HTTP/1.1\r\nHost: $host\r\nContent-type: application/x-www-form-urlencoded\r\n{$others}User-Agent: $useragent\r\nContent-length: ".strlen($query)."\r\nConnection: close\r\n\r\n$query";
$h=fsockopen($host,80);
fwrite($h,$post);
for($a=0,$r='';!$a;){
$b=fread($h,8192);
$r.=$b;
$a=(($b=='')?1:0);
}
fclose($h);
return $r;
}
function get($host,$query,$others='') { Global $useragent;
$path=explode('/',$host);
$host=$path[0];
unset($path[0]);
$path='/'.(implode('/',$path));
$post="GET $path HTTP/1.1\r\nHost: $host\r\nContent-type: application/x-www-form-urlencoded\r\n{$others}User-Agent: $useragent\r\nContent-length: ".strlen($query)."\r\nConnection: close\r\n\r\n$query";
$h=fsockopen($host,80);
fwrite($h,$post);
for($a=0,$r='';!$a;){
$b=fread($h,8192);
$r.=$b;
$a=(($b=='')?1:0);
}
fclose($h);
return $r;
}
//ESEMPIO
$host = "www.sito.com";
$query = "var=54&prova=si";
$altro = "";
echo $test = post($host,$query,$altro);