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 关于Java对接海康威视车牌识别一体机SDK是否需要固定外网的IP?
  • ¥15 Linux扩容时,格式化卡住了:vgdispaly查看卷组信息,没有输出
  • ¥18 关于#ubuntu#的问题:使用背景-工作职责内有七八台ubuntu系统的电脑,平时需要互相调取资料,想实现把这几台电脑用交换机组成一个局域网,来实现指定文件夹的互相调取和写入
  • ¥20 求一个简易射频信号综测仪
  • ¥15 esp8266 tally灯 接收端改为发射端
  • ¥30 Labview代码调用access 数据库,相同代码其中一个调用不出来是为什么
  • ¥15 基于51单片机的交通灯系统,找改程序有点急
  • ¥15 java启动jar包后,运行过程中宕机
  • ¥15 进行LM运算过程中出现了无法识别的问题,具体问题如下图
  • ¥500 高有偿提问!求优化设计微信小程序