我试图在Google日历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}在/data16/lokys/html/trestGoogle/pphpGoogle/library/Zend/Gdata/AuthSub.php第138行抛出
网上的应用程序在这里http://lokys.cz/testGoogle/calendar.php所以你可以试试这个问题。你有人能帮我吗?
谢谢。
请尝试添加
session_start((;
顶部。
我也遇到了同样的问题,但它发生在页面重新加载时。我认为当会话未启动时,一次性令牌无法升级为会话令牌。
希望得到帮助。