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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条