<? 
function pullpage( $method, $host, $usepath, $postdata = "" ) { 
  $fp = fsockopen( $host, 80, &$errno, &$errstr, 120 ); 
 
  $ua = "yourUserAgent/1.0"; 
 
 if( !$fp ) { 
   print "$errstr ($errno)<br>\n"; 
 } 
 else { 
   if( $method == "GET" ) { 
       fputs( $fp, "GET $usepath HTTP/1.0\n" ); 
   } 
   else if( $method == "POST" ) { 
       fputs( $fp, "POST $usepath HTTP/1.0\n" ); 
   } 
 
   fputs( $fp, "User-Agent: ".$ua."\n" ); 
   fputs( $fp, "Accept: */*\n" ); 
   fputs( $fp, "Accept: image/gif\n" ); 
   fputs( $fp, "Accept: image/x-xbitmap\n" ); 
   fputs( $fp, "Accept: image/jpeg\n" ); 
 
   if( $method == "POST" ) { 
       $strlength = strlen( $postdata ); 
 
       fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" ); 
       fputs( $fp, "Content-length: ".$strlength."\n\n" ); 
       fputs( $fp, $postdata."\n" ); 
   } 
 
   fputs( $fp, "\n" ); 
 
   $output = ""; 
 
      while( !feof( $fp ) ) { 
       $output .= fgets( $fp, 1024 ); 
   } 
 
   fclose( $fp ); 
 } 
 
 return $output; 
 } 
 
/* 
To call pullpage() via HTTP POST, do the following: 
 
$return_content = pullpage("POST", "this.server.com", "/cgi-bin/usethis.cgi", "yourdata1=value1&yourdata2=value2" ); 
 
*/ 
 
?>