how to access xml file from a protected directory??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

how to access xml file from a protected directory??

Post 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
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

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

Post by susrisha »

tried but failed. i got one more glitch. the password has an @ symbol in it.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

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

Post 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.
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

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

Post by susrisha »

Thanks alott.. that helped.. McInfo. :)
Post Reply