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
Need simplexml_load_file through a proxy
Moderator: General Moderators
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.
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.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
what about using simplexml_load_string()
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
$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