Kirk
Kirk

Reputation: 108

How do I solve this error? Trying to call data from a public

I'm trying to call data from the Google Calendar API with help from this tutorial and it's returning getting a php error:

Fatal error: Call to undefined function: simplexml_load_file() in \NAWINFS02\home\users\web\b872\rh.urbanpromise\new\loadcalendar.php on line 9

The server is running PHP Version 4.4.8

System: Windows NT IIS01501 5.2 build 3790

The website is currently hosted at readyhosting.com (I'm in the process of switching to a better host)

Any ideas on how to fix the error? (Thanks in advance)

This is my current code:

<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>     

Upvotes: 0

Views: 925

Answers (2)

davidtbernal
davidtbernal

Reputation: 13684

As Mr-sk points out, SimpleXML required PHP 5. There are, however, various attempts out there to port it to PHP 4:

I haven't used any of these, so I cannot provide any further insight. The other option would be to use DOM XML which is an official PHP4 extension, but is a bit harder to work with than simpleXML, depending on your familiarity with the DOM.

Or just upgrade to PHP 5. It's really about time to do so.

Upvotes: 2

mr-sk
mr-sk

Reputation: 13407

The SimpleXML extension requires PHP 5.

Upvotes: 5

Related Questions