我尝试在 Google Calendar API 中做一些应用。根据此https://developers.google.com/google-apps/calendar/v1/developers_guide_php#RetrievingCalendars手册,我做了一切必要的事情来检索经过身份验证的用户的日历列表。我写这段代码
<?php
$clientLibraryPath = 'phpGoogle/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
function getCurrentUrl()
{
return "http" . (($_SERVER["HTTPS"] == "on") ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
function getAuthSubUrl()
{
$next = getCurrentUrl();
$scope = 'https://www.google.com/calendar/feeds/';
$secure = false;
$session = true;
return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure,
$session);
}
$authSubUrl = getAuthSubUrl();
echo "<a href=\"$authSubUrl\">login to your Google account</a>";
if(! isset($_SESSION['sessionToken']) && isset($_GET['token'])) {
$_SESSION['sessionToken'] =
Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
}
$client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']);
echo $_SESSION['sessionToken'];
function outputCalendarList($client)
{
$gdataCal = new Zend_Gdata_Calendar($client);
$calFeed = $gdataCal->getCalendarListFeed();
echo '<h1>' . $calFeed->title->text . '</h1>';
echo '<ul>';
foreach ($calFeed as $calendar) {
echo '<li>' . $calendar->title->text . '</li>';
}
echo '</ul>';
}
?>
并且在用户身份验证之后,它给了我这个错误致命错误:未捕获的异常'Zend_Gdata_App_AuthException',消息'令牌升级失败。原因:令牌被撤销。
令牌被撤销。
错误 403
' 在 /data16/lokys/html/testGoogle/phpGoogle/library/Zend/Gdata/AuthSub.php:138 堆栈跟踪:#0 /data16/lokys/html/testGoogle/calendar.php(26): Zend_Gdata_AuthSub::getAuthSubSessionToken( '1/G3lMsmGM7mQgt...') #1 {main} 在第 138 行的 /data16/lokys/html/testGoogle/phpGoogle/library/Zend/Gdata/AuthSub.php 中抛出网络上的应用程序在这里http://lokys.cz/testGoogle/calendar.php所以你可以试试这个问题。你能帮我吗?
谢谢你。