【问题标题】:How do I solve this error? Trying to call data from a public我该如何解决这个错误?试图从公众中调用数据
【发布时间】:2010-03-04 18:45:05
【问题描述】:

我正在尝试在this tutorial 的帮助下从 Google 日历 API 调用数据,但它返回了一个 php 错误:

致命错误:调用未定义函数:第 9 行 \NAWINFS02\home\users\web\b872\rh.urbanpromise\new\loadcalendar.php 中的 simplexml_load_file()

服务器正在运行 PHP 版本 4.4.8

系统:Windows NT IIS01501 5.2 build 3790

该网站目前托管在 readyhosting.com(我正在切换到更好的主机)

关于如何修复错误的任何想法? (提前致谢)

这是我当前的代码:

<html>
<body>
<?php
$userid = 'username%40googlemail.com';
$magicCookie = 'cookie';
// build feed URL
$feedURL = "http://www.google.com/calendar/feeds/userid/private-magicCookie/basic";
// read feed into SimpleXML object
$sxml = simplexml_load_file($feedURL);
// get number of events
$counts = $sxml->children('http://a9.com/-/spec/opensearchrss/1.0/');
$total = $counts->totalResults; 
?>
<h1><?php echo $sxml->title; ?></h1>
<?php echo $total; ?> event(s) found.
<p/>
<ol>
<?php    
// iterate over entries in category
// print each entry's details
foreach ($sxml->entry as $entry) {
$title = stripslashes($entry->title);
$summary = stripslashes($entry->summary);
echo "<li>\n";
echo "<h2>$title</h2>\n";
echo "$summary <br/>\n";
echo "</li>\n";
}
?>
</ol>
</body>
</html>     

【问题讨论】:

  • 这和应用引擎有什么关系?

标签: php xml api


【解决方案1】:

SimpleXML 扩展需要 PHP 5。

【讨论】:

  • 嗯,这很简单。
  • 嘿,我们最好的人,不用担心!
【解决方案2】:

正如 Mr-sk 所指出的,SimpleXML 需要 PHP 5。但是,有各种尝试将其移植到 PHP 4:

我没有使用任何这些,所以我无法提供任何进一步的见解。另一种选择是使用DOM XML,它是官方的 PHP4 扩展,但比 simpleXML 更难使用,具体取决于您对 DOM 的熟悉程度。

或者只是升级到 PHP 5。真的是时候这样做了。

【讨论】:

    猜你喜欢
    • 2016-07-21
    • 2016-09-09
    • 2015-02-28
    • 2013-08-16
    • 2020-04-17
    • 1970-01-01
    相关资源
    最近更新 更多