0

我正在尝试将谷歌日历集成到我的 codeIgniter 应用程序中。API 中有一个我不理解的细节。为了授权应用程序访问 google 帐户,使用了 OAuth2。在设置应用程序的名称、客户端 ID 等之后,应该执行以下操作(根据教程):

if ($this->input->get('code')) 
{
    $client->authenticate();
    $_SESSION['token'] = $client->getAccessToken();
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}

if (isset($_SESSION['token'])) 
{ 
    $client->setAccessToken($_SESSION['token']);
}

if ($client->getAccessToken()) 
{ 
    $activities = $plus->activities->listActivities('me', 'public');
    print 'Your Activities: <pre>' . print_r($activities, true) . '</pre>';

    // We're not done yet. Remember to update the cached access token.
    // Remember to replace $_SESSION with a real database or memcached.
    $_SESSION['token'] = $client->getAccessToken();
} 
else 
{
    $authUrl = $client->createAuthUrl();
    print "<a href='$authUrl'>Connect Me!</a>";
}

我这样做了,但我总是被重定向到“连接我”页面。我真的不明白这个 com 是什么意思:

// We're not done yet. Remember to update the cached access token.
// Remember to replace $_SESSION with a real database or memcached.

谢谢您的帮助

4

0 回答 0