Click to See Complete Forum and Search --> : File open url


st33d
12-29-2006, 12:28 PM
I'm building a script to grab text and content from a html. The content gets rebuilt into an XML to give to Flash.

I've got a basic version running using this xml2html parser (http://planet.keks.com/about/index.php). I just use Flash to parse the garbage that gets returned from;

http://www.robotacid.com/assets/toxml.php

eg:

http://www.robotacid.com/assets/toxml.php?url=http://www.robotacid.com/splash.html

But I would rather be building an XML that Flash can read without getting Flash to do all the hard work (ie: CDATA tags, image files as separate nodes, etc.), but I don't know how to open a remote file for reading. The following code doesn't work:

$url = $_GET['url'];
$fp = fopen($url, 'r') or die("failed to open html");
$fileString = fread($fp, filesize($url));
fclose($fp);

I get a no such file or directory.

The XML parser seems to able to read from any address, but I can't isolate the commands responsible. Can anyone help me please?

NightShift58
12-29-2006, 12:56 PM
You're probably getting "stuck" on the remote filesize().

You need to take a look at: http://www.php.net/manual/en/function.file-get-contents.php

If your host doesn't allow file_get_contents() then try your hand at cURL, if that's available on your system (http://www.php.net/manual/en/ref.curl.php)