Forum Moderators: coopster

Message Too Old, No Replies

HTTP Authorisation problem, unable to open remote files.

But can do it fine on another host, its driving me nuts ;)

         

kensplace

11:43 pm on Sep 23, 2004 (gmt 0)



Can anyone help?

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]

Timotheos

3:44 am on Sep 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably not it but is allow_url_fopen [php.net] enabled?

jollymcfats

3:31 pm on Sep 24, 2004 (gmt 0)

10+ Year Member



Or maybe that host's network is directing outbound web traffic through a proxy?

I might try doing a request by hand from the host's command line, using either telnet or wget or something. If that breaks, there's something in the network. If it works, the problem is with PHP.