|
Posted by Al on 01/12/06 22:00
As for the original question... If your server has cURL support, try
using that:
It works like fopen with URLs when that feature is disabled.
I stole this from a firefox XML feed ticker code but here's the basic
script:
<?php
function getResponse($url, $port, $timeout) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_PORT, $port);
$data = curl_exec($ch);
curl_close($ch);
if ($data === NULL)
return "Error"; // i assume this where you decide if the
server's down or whatever you wanted to do
return $data;
}
$infoFromSite = getResponse("http://www.example.com/", 80, 25);
echo
"<html><head></head><body><pre>".htmlentities($infoFromSite)."</pre></body></html>";
?>
Navigation:
[Reply to this message]
|