Saturday, 15 May 2010

php - How to open an http file with fopen()? -


I need to open a http external XML file, then replace some text and save the file in my site host is. / P>

Something like this:

  & lt; Php $ xml_external_path = 'http://someplace.com/external_file.xml'; $ Xml_external = fopen ($ xml_external_path, "w +"); // code to replace text here $ xml_local_path = 'http://www.misite.com/local_file.xml'; $ Xml_local = fopen ($ xml_sw_path, "w +"); FILIT ($ xml_local, $ xml_external); Fclose ($ xml_external); Fclose ($ xml_local); ? & Gt;  

The problem is that I get this message:

WARNING: PHONON (): Failed to open stream: HTTP cover, writable connections not supported Does ..

WARNING: FOPN (): Failed to open stream: HTTP wrapper does not support writeable connection to ...

Both files are writeable Are there.

You do not want to write to the address. Simply replace + w with r .

  $ xml_external_path = 'http://someplace.com/external_file.xml'; $ Xml_external = fopen ($ xml_external_path, "r"); ....  

Take a look at the examples.

You can also use the function.

  file_get_contents ("http://someplace.com/external_file.xml");  

No comments:

Post a Comment