I'm making an application using blogger api from google.
what I want is when successful login I can display all the blogs that I have on the blog spot,
I have 2 blogs on blogspot blog-api-test.blogspot.com and blog-api-test-2.blogspot.com
I have successfully logged in with the following code, and in this project I use google-api-php-client and use the service provided, so how can I display an option to choose both of my blogs?
my simple code
<?php
require 'init.php';
if (!$oauth_credentials = getOAuthCredentialsFile()) {
echo missingOAuth2CredentialsWarning();
return;
}
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$client = new Google_Client();
$client->setAuthConfig($oauth_credentials);
$client->setRedirectUri($redirect_uri);
$client->addScope(Google_Service_Blogger::BLOGGER);
$service = new Google_Service_Blogger($client);
if (isset($_GET['code'])) {
$token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
$client->setAccessToken($token);
// store in the session also
$_SESSION['upload_token'] = $token;
// redirect back to the example
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
// set the access token as part of the client
if (!empty($_SESSION['upload_token'])) {
$client->setAccessToken($_SESSION['upload_token']);
if ($client->isAccessTokenExpired()) {
unset($_SESSION['upload_token']);
}
} else {
$authUrl = $client->createAuthUrl();
}
?>
<div class="box">
<?php if (isset($authUrl)): ?>
<div class="request">
<a class='login' href='<?= $authUrl ?>'>Login Now</a>
</div>
<?php endif ?>
</div>
or from what I want you guys to have a tutorial?