【发布时间】:2013-10-18 18:02:54
【问题描述】:
我尝试在 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',消息'令牌升级失败。原因:令牌被撤销。 令牌已撤销。
Error 403
' in /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} 抛出 /data16/lokys/html/testGoogle/phpGoogle/library/Zend/第 138 行的 Gdata/AuthSub.php
网络应用在这里http://lokys.cz/testGoogle/calendar.php,所以你可以试试这个问题。有人能帮帮我吗?
谢谢。
【问题讨论】: