Reading Remote Files With FOPEN:
This appears to be quite a common problem for installations that run a
really tight ship. I am trying to do some XML and have a slight problem:
My hosting company does not allow for file sockets. I assume that this
means that allow_url_fopen will not work.
Example
<?php
if (!($fp = fopen($url, "r"))) {
die("could not open XML input");
}
?>
NOTE: This works fine if the file is local.
The following is supposed to work by overriding the default php.ini but
sadly, does not work on my installation.
Sample Newsfeed in XML format
Or setting the ini file:
<?php
$feed = 'http://slashdot.org/slashdot.rdf';
ini_set('allow_url_fopen', true);
$fp = fopen($feed, 'r');
$xml = '';
while (!feof($fp)) {
$xml .= fread($fp, 128);
}
fclose($fp);
The result is either getting a message stating that the file could not
be opened or that the file does not exist in the directory. The file
pointer does not seem to recognize the scheme (http) versus file
protocol sometimes?
My question is, has anybody got a reasonable work around for reading
remote files from an http server (must be port 80 not ftp port 21) that
does not require using any commands from the file sockets set (fopen,
fsock...)
OR...
What am I missing here to get the fopen to work when fsockets are NOT
ALLOWED.
NOTE: Yahoo Web Hosting is my provider. They have not yet responded to
my query regarding file sockets and their policies. I cannot change the
PHP installation so I may be not be able to do XML at all.
Any thoughts or comments would be greatly appreciated.
Thanks,
Bill
http://www.zappersoftware.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php