Публикация в Blogger с меткой и описанием поиска с помощью Blogger PHP API v 3.0

Я хочу опубликовать в Blogger ярлык и описание поиска.
Я получил ссылку от 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);
}

После этого поста я зашел в блоггер.
Я могу видеть вышеупомянутый пост там. В этом сообщении есть «Заголовок сообщения» и «Тело сообщения», но нет «ярлыка» и «Поискового описания».

введите описание изображения здесь
Как я могу публиковать сообщения с метками и описанием поиска?

Является ли это возможным?

2

Решение

Вы должны использовать:

$NewPost = new Google_Service_Blogger_Post();
$NewPost->setLabels(array('Label1', 'Label2'));
-2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector