无法从我的codeIgniter项目访问Google帐户

时间:2012-08-21 15:06:40

标签: codeigniter oauth-2.0 account

我正在尝试将google日历集成到我的codeIgniter应用程序中。我在API中有一个细节,我没有理解。 为了授权应用程序访问Google帐户,使用了OAuth2。设置应用程序的名称后,客户端ID,ect,这里应该做什么(根据tuto):

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.

感谢您的帮助

0 个答案:

没有答案