Post to Blogger with label and search description using Blogger PHP API v 3.0
Raj <[email protected]>
| Newsgroups | gmane.comp.web.blogger.api |
|---|---|
| Message-ID | <[email protected]> |
Currently i have posting to Blogger by Email. Email subject as post title
and email body as post body. Its working.
I want to post with label and search description. I got a link from google
https://github.com/google/google-api-php-client/blob/master/src/Google/Service/Blogger.php
$scriptUri = "https://".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF'];
require_once 'google-api-php-client-master/src/Google/autoload.php';
$client = new Google_Client();
$client->setApplicationName("BloggerAPI");
$client->setDeveloperKey("AIzaSysdCMlzJM2SsdxuEEdS-l9r2MxLgcfxylE2Bzc");
$client->setAccessType('online');
$client->setClientId("699839154993-7423kasdsdeibmi00ss1bk94plu5gi7ioene.apps.googleusercontent.com");
$client->setClientSecret("82cVvhOy5z3hsW2Ur4fgdfg8QXaBR");
$client->setRedirectUri($scriptUri);
$client->setScopes(array('https://www.googleapis.com/auth/blogger')); //since we are going to use blogger services
$bloggerService = new Google_Service_Blogger($client);
if (isset($_GET['logout'])) { // logout: destroy token
unset($_SESSION['token']);
die('Logged out.');
}
if (isset($_GET['code'])) { // we received the positive auth callback, get the token and store it in session
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
}
if (isset($_SESSION['token'])) { // extract token from session and configure client
$token = $_SESSION['token'];
$client->setAccessToken($token);
}
if (!$client->getAccessToken()) { // auth call to google
$authUrl = $client->createAuthUrl();
header("Location: ".$authUrl);
die;
}
$posts = $bloggerService->posts;
$NewPost = new Google_Service_Blogger_Post();
$NewPost->setTitle("Post Title ".time());
$NewPost->setLabels("Post Label1");
$NewPost->setContent("Post Content!!!!");
$NewPost->setCustomMetaData("Custom Meta Data ".time());
try
{
$nposts = $posts->insert("310034677540144362",$NewPost);
}
catch(Exception $e)
{
print_r($e);
}
After this post, then i logged into blogger. I can see the above post
there. With this post has 'Post Title' and 'Post Body', but it has no
'label' and 'Search description'.
[image: enter image description here] <http://i.stack.imgur.com/xzCRs.png>
How can i post with 'label' and 'Search description'.
--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.