我正在 IBM.com 上编写使用 Zend 框架与 Google Calendar API 配合使用的教程。我确实从教程中复制了一段代码并尝试使用它,但它似乎不起作用。我的 php 文件包括以下内容:
<!--Some HTML is above here-->
<body>
<?php
// load library
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
Zend_Loader::loadClass('Zend_Http_Client');
// create authenticated HTTP client for Calendar service
$gcal = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$user = "username@gmail.com"; //replace with my username
$pass = "pass"; //replace with my password
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $gcal);
$gcal = new Zend_Gdata_Calendar($client);
// generate query to get event list
$query = $gcal->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('basic');
// get and parse calendar feed
// print output
try {
echo "<!--this comment is seen-->\n";
$feed = $gcal->getCalendarEventFeed($query);
echo "<!--this comment is not seen-->\n";
} catch (Zend_Gdata_App_Exception $e) {
//this doesn't happen.
echo "Error: " . $e->getResponse();
}
?>
<h1><?php echo $feed->title; ?></h1>
<?php echo $feed->totalResults; ?> event(s) found.
<p/>
<ol>
</body>
从字面上看,我对此代码所做的唯一更改是用我自己的电子邮件地址和密码替换用户名和密码。当代码执行到达 try 块中的语句时,它似乎失败了,但没有被 catch 块捕获,即使我将它更改为捕获任何异常,而不仅仅是Zend_Gdata_App_Exception
. 生成的页面源代码清楚地表明 PHP 正在崩溃,但是:
<!--Some HTML is above here-->
<body>
<!--this comment is seen-->
之后什么都没有。我在这里动态学习 PHP,所以任何帮助将不胜感激!