Page 1 of 1

how to access xml file from a protected directory??

Posted: Sat Jul 04, 2009 8:15 am
by susrisha
Hello,
I have an xml file located at http://develop.leadapps.com/onlineradio ... unties.xml

I have written a php code which will print out all the content

Code: Select all

 
$mybounties=simplexml_load_file("http://develop.leadapps.com/onlineradio1/supportFramework/bounties.xml");
echo $mybounties->asXML();
 
The problem is that http://develop.leadapps.com/onlineradio ... Framework/ folder is password protected. So i will need to have to login using htaccess to get into the directory.
Here is the error output that i got

Code: Select all

 
Warning: simplexml_load_file(http://develop.leadapps.com/onlineradio ... unties.xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in D:\Dev\Apache Software Foundation\Apache2.2\htdocs\dummyproject\forumquestion.php on line 4
 
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://develop.leadapps.com/onlineradio1/supportFramework/bounties.xml" in D:\Dev\Apache Software Foundation\Apache2.2\htdocs\dummyproject\forumquestion.php on line 4
 
Fatal error: Call to a member function asXML() on a non-object in D:\Dev\Apache Software Foundation\Apache2.2\htdocs\dummyproject\forumquestion.php on line 5
 
another way to do is to go for a curl execution and get the results as it is by using a user proxy.
But i am not sure.. Will try out. But please let me know if that can be done using curl execution and if so how??
Thanks in advance

Re: how to access xml file from a protected directory??

Posted: Mon Jul 06, 2009 4:50 am
by susrisha
tried but failed. i got one more glitch. the password has an @ symbol in it.

Re: how to access xml file from a protected directory??

Posted: Mon Jul 06, 2009 1:31 pm
by omniuni
Do you have access to the server on which the file is hosted? If so, create a simple proxy script that looks to see if the request is coming from the target server, and if so, returns the XML.

Re: how to access xml file from a protected directory??

Posted: Tue Jul 07, 2009 1:39 am
by susrisha
Thanks alott.. that helped.. McInfo. :)