From: Michael Stroh on
I've created a php file (getcalentries.php) that creates an xml output and have a second page (plots_test.php) that reads in the xml file and displays some plots. They've both in the same webdav folder so I have to enter authentication information to load the plotting page, but my simplexml_load_file command is failing to load:

Warning: simplexml_load_file(https://www.mydomain.com/secure/getcalentries.php?id=0&start=2010-05-17&end=2010-05-31) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /path/secure/plots_test.php on line 24

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "https://www.mydomain.com/secure/getcalentries.php?id=0&start=2010-05-17&end=2010-05-31" in /path/secure/plots_test.php on line 24
Feed not loading

The xml file works fine because I can move it to the parent directory just above the secure folder and it will work fine. My question is how do I need to load the file so that the authentication information can get passed? I'd really prefer to keep the xml file behind the webdav folder authentication.

Thanks in advance!

Michael

From: Nathan Nobbe on
On Mon, May 17, 2010 at 4:01 PM, Michael Stroh <stroh(a)astroh.org> wrote:

> I've created a php file (getcalentries.php) that creates an xml output and
> have a second page (plots_test.php) that reads in the xml file and displays
> some plots. They've both in the same webdav folder so I have to enter
> authentication information to load the plotting page, but my
> simplexml_load_file command is failing to load:
>
> Warning: simplexml_load_file(
> https://www.mydomain.com/secure/getcalentries.php?id=0&start=2010-05-17&end=2010-05-31)
> [function.simplexml-load-file]: failed to open stream: HTTP request failed!
> HTTP/1.1 401 Authorization Required in /path/secure/plots_test.php on line
> 24
>
> Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning
> : failed to load external entity "
> https://www.mydomain.com/secure/getcalentries.php?id=0&start=2010-05-17&end=2010-05-31"
> in /path/secure/plots_test.php on line 24
> Feed not loading
>
> The xml file works fine because I can move it to the parent directory just
> above the secure folder and it will work fine. My question is how do I need
> to load the file so that the authentication information can get passed? I'd
> really prefer to keep the xml file behind the webdav folder authentication.


youre asking for the file through an fopen wrapper (or similar) meaning some
vanilla code is being used to download the xml file from the remote server.
if you want to specify credentials for an http connection why dont you try
curl. also you might try stream contexts, however, i dont think those are
supported by the simplexml functions.

short version - pull down the file w/ curl then feed it to simplexml
locally.

-nathan