Closed GoogleCodeExporter closed 8 years ago
You'll need to use the latest version of the client library on trunk
http://code.google.com/p/google-api-php-client/source/checkout.
New auto approval functionality:
$client->setApprovalPrompt('auto');
New 'online' access type:
$client->setAccessType('online');
As for the redirect_uri_mismatch error, you need register your redirect uri
within the google api console.
Example using auto approval:
$client = new apiClient();
$client->setApplicationName("Google+ PHP Starter Application");
$client->setApprovalPrompt('auto');
// Visit https://code.google.com/apis/console?api=plus to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId('insert_your_oauth2_client_id');
$client->setClientSecret('insert_your_oauth2_client_secret');
$client->setRedirectUri('insert_your_oauth2_redirect_uri');
$client->setDeveloperKey('insert_your_developer_key');
$plus = new apiPlusService($client);
if (isset($_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()) {
$me = $plus->people->get('me');
print "Your Profile: <pre>" . print_r($me, true) . "</pre>";
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Connect Me!</a>";
}
Original comment by chirags@google.com
on 12 Dec 2011 at 5:03
Original comment by chirags@google.com
on 14 Dec 2011 at 10:17
Original issue reported on code.google.com by
nash...@gmail.com
on 12 Dec 2011 at 11:59