dtzh131555
dtzh131555
2013-06-04 19:08

使用PHP输出从.XML文件中获取Wufoo表单数据

已采纳

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!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • douye9175 douye9175 8年前

    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)

    点赞 评论 复制链接分享