Skip to main content
Participant
September 11, 2006
Question

Using cURL instead of fopen() in XSLTransform

  • September 11, 2006
  • 2 replies
  • 685 views
I don't know much code, so I followed the tutorial in the Dreamweaver Dev community to create an XSLT fragment and place it into a PHP page. The problem I am having is that I am trying to "consume" an RSS feed on another website, but the host for my site does not allow fopen() for security reasons. Their documentation suggests using cURL instead, but I have no idea how to do this. Could someone help me out?

My MM_XMLTransform.class.php, automatically generated by Dreamweaver is attached. The URL of the remote feed I am trying to consume is http://www.weather.gov/alerts/wwarssget.php?zone=VAZ094.

This topic has been closed for replies.

2 replies

February 20, 2007
http://forum.dreamhosters.com/programming/47032-Using-cURL-to-fetch-a-web-page.htm hosts the solution. You just need the cUrl-bit to write to a local xml file (so make sure it's writable), then feed this local XML to the transformer. Pretty easy, even for a novice coder like me. A great way to circumvent the 'fopen'-limitation.
Participant
February 23, 2007
grumble - those are not easy at all for those of us that prefer our code hidden ;)

can someone tell me exactly what lines to replace in MM_XSLTransform?

the only thing I see is something like $magic_quotes_runtime_orig = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
if ($myFile = @fopen($mySrc, 'rb')) {
while ($data = fread($myFile, 2048)) {
$fileContent .= $data;
}
fclose($myFile);

-- perhaps someone wants to make a new class file available that uses cURL???
Participant
January 23, 2007
Bump.

I'm having the same problem. Granted, the hosting providers in question are only trying to protect people who aren't master coders from themselves with added security measures. But isn't that the whole point of using Dreamweaver to do this? So that I don't have to know how to write all of the code myself? Adobe should release an updated version of MM_XSLTransform.class.php to address this...

In the meantime, while we're waiting for pigs to fly, anyone else have a solution?
hmmcnuAuthor
Participant
January 23, 2007
Wow, I forgot I had posted this topic.

I found a solution just recently. Actually, it's a simple solution to replace the include(), fopen() and fsockopen() arguments. I haven't applied it to my code originally posted here, but I have gotten it to work with another page.

See attached code. Also see these sites:
cURL in PHP
cURL in PHP (update)
Practical PHP
PHPit