Here is a quick function I wrote up for retrieving webpages...
function openURL($host,$port,$page,$user_agent='PHP',$referer='',$withHeaders=FALSE) {
// Open a connection to the webserver
$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
return false;
// Request the page
fputs($fp,"GET $page HTTP/1.0\r\n");
fputs($fp,"User-agent: $user_agent\r\n");
if($referer)
fputs($fp,"Referer: $referer\r\n");
fputs($fp,"\r\n");
// Read the response
while(!feof($fp))
$document .= fgets($fp,2048);
if(!$withHeaders)
list($headers,$document) = explode("\r\n\r\n",$document);
// Close the Connection
fclose($fp);
return $document;
}
And here is an example of its usage...
$webpage_data = openURL("www.yoursite.com",80,"/","My Special Internet Browser","www.referer.com",FALSE);
You MUST specify a page to load. If you want to get the main page on phpbuilder.com for example, you would use "www.phpbuilder.com" as the host and "/" as the page. If you wanted to get the articles section, you woudl use "www.phpbuilder.com" as the host, and "/columns/" as the page.
Hope this helps you out,
-Josh B