I’m working on a snippet that connects to a google calendar. I know the php code I’ve tested the php code outside of modx and it works. However, when i paste my code into modx snippets i get the following error:
PHP error debug
Error: Zend_Loader::include_once(Zend/Gdata/Calendar/Extension/EventQuery.php) [function.Zend-Loader-include-once]: failed to open stream: No such file or directory
Error type/ Nr.: Warning - 2
File: /home/gbc/public_html/assets/snippets/CalendarListing/library/Zend/Loader.php
Line: 83
Line 83 source: include_once $file;
My php code up to the error is here:
<?php
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $modx->config['base_path'].'assets/snippets/CalendarListing/library/');
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata','Zend/Gdata');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
$three_months_in_seconds = 60 * 60 * 24 * 28 * 3;
$three_months_ago = date("Y-m-d\Th:i:sP", time() - $three_months_in_seconds);
$three_months_from_today = date("Y-m-d\Th:i:sP", time() + $three_months_in_seconds);
// Create an instance of the Calendar service without authentication,
// for read-only access to a public feed
$service = new Zend_Gdata_Calendar($client);
$query = $service->newEventQuery();
echo "HERE";
$query->setUser('*********@gci.net');
$query->setVisibility('public');
$query->setProjection('full');
$query->setOrderby('starttime');
//$query->setStartMin($three_months_ago);
//$query->setStartMax($three_months_from_today);
// Retrieve the event list from the calendar server
try {
$eventFeed = $service->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getResponse();
}
// Iterate through the list of events, outputting them as an HTML list
for($i=0;$i < 7; $i++) {
$event = $eventFeed[$i];
print "<div id='page_link'><a href='#'><span>" . $event->title . "</span></a></div>\n";
$startTime = $event->when->startTime;
// print '<div id="page_link">' . date("l jS \o\f F Y - h:i A", strtotime( $startTime ) );
// Google Calendar API's support of timezones is buggy
// print " AST</div>\n";
//print "<li>" . $event->where->valueString . "</li>\n";
}
?>
I never see the output for "HERE" so the breakdown is probably the line before it. My hunch is it has to do with the way modx runs php scripts, but I’m not sure. The part that baffles me is that this code works outside of the snippet. Anybody have suggestions or a solution?