Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法从我的codeIgniter项目访问google帐户_Codeigniter_Oauth 2.0_Account - Fatal编程技术网

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

无法从我的codeIgniter项目访问google帐户,codeigniter,oauth-2.0,account,Codeigniter,Oauth 2.0,Account,我正在尝试将google日历集成到我的codeIgniter应用程序中。API中有一个细节我没有理解。 为了授权应用程序访问google帐户,使用了OAuth2。在设置应用程序的名称、客户端ID等之后,下面是应该做的事情(根据图图): 谢谢你的帮助你能不能先让你的代码有点可读性。谢谢这到底是在哪一步失败的?当我点击Connect Me并连接我的google帐户时,它会将我重定向到同一个页面“Connect Me”$此->输入->获取('code'),(isset($\u会话['token'])和

我正在尝试将google日历集成到我的codeIgniter应用程序中。API中有一个细节我没有理解。 为了授权应用程序访问google帐户,使用了OAuth2。在设置应用程序的名称、客户端ID等之后,下面是应该做的事情(根据图图):


谢谢你的帮助

你能不能先让你的代码有点可读性。谢谢这到底是在哪一步失败的?当我点击Connect Me并连接我的google帐户时,它会将我重定向到同一个页面“Connect Me”$此->输入->获取('code'),(isset($\u会话['token'])和$client->getAccessToken())的计算结果总是错误的。当从Google重定向回时,您重定向到哪个URL?(请随意混淆任何键)@JoachimIsaksson与我在$client->setRedirectUri('*********/index.php/public/calendar')中输入的URL相同,它是我网站的主页
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>";
}
// We're not done yet. Remember to update the cached access token.
// Remember to replace $_SESSION with a real database or memcached.