是什么导致“对非对象调用... getCalendarListFeed()”错误?

时间:2011-01-25 00:50:20

标签: php google-api google-calendar-api gdata

我有以下代码:

<?php
require_once('Zend/Loader.php');
$classes = array('Zend_Gdata','Zend_Gdata_Query','Zend_Gdata_ClientLogin','Zend_Gdata_Calendar');
foreach($classes as $class) {
    Zend_Loader::loadClass($class);
}
$user = 'me@gmail.com';
$pass = 'MyPassword';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);
$service = $Zend_Gdata_Calendar[$client];

$listFeed = $service->getCalendarListFeed();

此代码返回Call to a member function getCalendarListFeed() on a non-object in MyCal.php on line 13

导致此错误的原因是什么?

1 个答案:

答案 0 :(得分:0)

我知道这有点过时,但请试一试!

$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client  = Zend_Gdata_ClientLogin::getHttpClient($email, $password, $service); 
$service = new Zend_Gdata_Calendar($client);