dtzh131555 2013-06-04 19:08
浏览 75
已采纳

使用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 2013-06-04 19:26
    关注

    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)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵