Forum Moderators: coopster
I have tried many methods to open remote files, and they all seem to fail with the same type of error.
They only fail on this host, but oddly, they work on another host I use, which leads me to believe its something to do with the host's setup.
The support people for the host dont think it is their problem tho, so Im looking for guidance as to what it could be, so I can get back to them with details, or find a workaround that works.
Examples of what fails (but do work on another host) are
quote:
<?php $res = file_get_contents('http://www.example.com/robots.txt');
echo $res;
?>
which fails with
quote:
Warning: file_get_contents(http://www.example.com/robots.txt): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in /home/content/l/s/b/lsblogs/html/x4.php on line 3
also fopen fails
example code extract, works on one domain, not on the other...
quote:
$testurl = "http://www.example.com/robots.txt"; $fp = fopen( $testurl, "r" ) or die( "<p>See error above, fopen failed for " . $testurl );
produces
quote:
Warning: fopen(http://www.example.com/robots.txt): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in /home/conten etc etc
Same for get_meta_tags, and it does not matter what url I use, I have tried many (all local urls work fine, its just remote ones!)
Does anyone know what the problem is?
Does anyone know a way to open a remote file that would work on this host? Or what to tell the host to check/alter so it will work?
thanks in advance!
[edited by: coopster at 11:51 pm (utc) on Sep. 23, 2004]
[edit reason] no urls as per TOS [webmasterworld.com] [/edit]