Specter All American 6575 Posts user info edit post |
I want to access a file that is on a server that has an SSL certificate as well as a username/password auth and save it to a string. This is what I'm trying:
$site = "https://user:pass@hostname"; $xml_page = file_get_contents($site); echo $xml_page;
This is what I'm getting:
Warning: file_get_contents(https://user:pass@hostname) [function.file-get-contents]: failed to open stream: No such file or directory in /usr/local/apache2/htdocs/xmlparser/parse.php on line 17
I'm not sure if openSSL is installed, but would that cause a "no such file" warning? What else could I try to accomplish this?
[Edited on March 9, 2009 at 5:10 PM. Reason : ]3/9/2009 5:08:01 PM |
philihp All American 8349 Posts user info edit post |
do you have libcurl installed?
http://blog.taragana.com/index.php/archive/how-to-use-curl-in-php-for-authentication-and-ssl-communication/ 3/9/2009 5:33:13 PM |
Shadowrunner All American 18332 Posts user info edit post |
have you tried using cURL?
[Edited on March 9, 2009 at 5:35 PM. Reason : philihp beat me to it; http://us3.php.net/curl anyway] 3/9/2009 5:34:05 PM |
mellocj All American 1872 Posts user info edit post |
open up a phpinfo() and see what allow_url_fopen is set to. If its set to 0 then it should disable opening a remote URL with file_get_contents
you may be able to override it with php_admin_value 3/9/2009 5:45:01 PM |
Specter All American 6575 Posts user info edit post |
I got it working with curl. However, I'm having a problem parsing a string containing xml code that is formatted the following way:
<?xml ...> <GetColorList> <ColorList> <Color Name="Red" IsDefined="0" IsPresent="1"> <Color Name="Blue" IsDefined="0" IsPresent="0"> <Color Name="Green" IsDefined="0" IsPresent="1"> </ColorList> </GetColorList>
How do I parse it in such a way where I can get just the color name and then the status of IsPresent displayed together, like so:
Red 1 Blue 0 Green 1
I've tried using explode() as well as a tokenizer, but I can't seem to think of a way to do this off the top of my head. I've also tried playing around with php's built-in xml parsers but it doesn't seem to work on the inside of the tags. Any advice would be greatly appreciated.
[Edited on March 16, 2009 at 12:13 PM. Reason : ]3/16/2009 12:11:11 PM |
qntmfred retired 40726 Posts user info edit post |
Quote : | "php's built-in xml parsers" |
keep looking
[Edited on March 16, 2009 at 12:14 PM. Reason : keyword xml node attribute]3/16/2009 12:13:51 PM |
Specter All American 6575 Posts user info edit post |
Anything in particular that might work in PHP4? 3/16/2009 2:21:53 PM |
qntmfred retired 40726 Posts user info edit post |
http://us2.php.net/manual/en/function.domattribute-value.php 3/16/2009 2:24:17 PM |