Search code examples
phpxmlexportwufoo

Grabbing Wufoo form data from .XML file using PHP to output


Basic Idea: I'm trying to take form entries (data) from Wufoo using their API and output them onto a specific page on our intranet.

So far: I have gathered that I need to use the Wufoo API (utilizing php and curl) to grab data from an .xml or json file and then I need to somehow format and organize the information using CSS or more preferably XSLT.

I am using their basic curl .php code provided that does give me an xml output.

<?php

$curl = curl_init('https://ccchurches.wufoo.com/api/v3/forms/UNIQUEID/entries.xml');

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl, CURLOPT_USERPWD, 'MY API:footastic');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERAGENT, 'Wufoo Sample Code');

$response = curl_exec($curl);
$resultStatus = curl_getinfo($curl);

if($resultStatus['http_code'] == 200) {
echo $response;
} else {
echo 'Call Failed '.print_r($resultStatus);
}


?>

The XML output appears inside the php file I created with the above code in it. The only way I have figured out how to style it this way is with CSS (.php files don't seem to be .xsl friendly), which is very limited and only formats the style and not also the organization of the data as I would prefer.

Any help would be much appreciated!


Solution

  • You should take the XML text and use SimpleXML

    Then you'll be able to navigate through the XML tree and make your own HTML output.

    You might want to start here: simplexml_load_string since you already have the XML from cURL ($response)