Google+ Login using CodeIgniter + PHP

6,021 views
Skip to first unread message

Hossein Jalali

unread,
Nov 19, 2013, 2:52:03 PM11/19/13
to google-api...@googlegroups.com
We are currently using the following library: https://github.com/samwierema/google-plus-api-codeigniter 

And our code works perfectly fine, we are able to getAccessToken but when we want to get people data it does not give us anything.

Our code looks like below (the section yellowed is where the code does not work):

Can anyone help figure this out?

Thank you.

function googleplus()
{
$this->load->library('googleplus');
if (isset($_GET['code'])) {
$this->googleplus->client->authenticate();
$_SESSION['token'] = $this->googleplus->client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if ($_SESSION['token'])
{
$this->googleplus->client->setAccessToken($_SESSION['token']);
}
if ($this->googleplus->client->getAccessToken())
{
$this->googleplus->people->get('115414977082318263605');
$activities = $this->googleplus->activities->listActivities('115414977082318263605', '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'] = $this->googleplus->client->getAccessToken();
}
else
{
$authUrl = $this->googleplus->client->createAuthUrl();
print "<a href='$authUrl'>Connect Me!</a>";
}
}
Reply all
Reply to author
Forward
0 new messages