Page 1 of 1

Need simplexml_load_file through a proxy

Posted: Tue Apr 04, 2006 3:18 pm
by CSTechie
I'm hoping that someone has experience using PHP 5's simplexml_load_file while connecting through a proxy.

I can't seem to get the right combination to make this all fly and maybe I can't actually use simplexml with a proxy. I've spent a fair bit of time getting nowhere fast so any and all help would be so very appreciated.

It works great if I just have a basic url to the rss feed, but as soon as I introduce a myriad of ways to use the proxy, the whole thing tanks and I haven't seen any examples of this combination out there, but I'm sure that many people have done this, right?

Help. Please. Thank you!!!

CS

Posted: Tue Apr 04, 2006 3:23 pm
by feyd
have you tried making requests through the proxy that aren't related to the simplexml extension?

Posted: Tue Apr 04, 2006 3:33 pm
by CSTechie
The short answer is yes.

I've used this and gotten back data in $index and switched to use simplexml_load_string vs simplexml_load_file

$options = array(
'http' => array(
'header' => "Proxy: http://www.proxyserver.com:80\r\n"
)
);

$context = stream_context_create($options);
$index = file_get_contents("$this->url_get",
false, $context);


But I've been very unsuccessful at getting the data to be read as xml data. I get different errors when I try different combinations, but I do know that the proxy works.

Posted: Tue Apr 04, 2006 3:42 pm
by feyd
what about using simplexml_load_string()

Posted: Tue Apr 04, 2006 3:59 pm
by CSTechie
I should have put this up from the start. This is what I have when I use simplexml_load_string()

$options = array(
'http' => array(
'header' => "Proxy: http://www.proxyserver.com:80\r\n"
)
);

$context = stream_context_create($options);
$index = file_get_contents("$this->url_get",
false, $context);

line 88: $xml_object = simplexml_load_string($index);



Output:

Warning: Entity: line 1: parser error : Start tag expected, '<' not found in file.php on line 88

Warning: $index in file.php on line 88

Warning: ^ in file.php on line 88