Я пытаюсь использовать API Календаря Google версии 3 (PHP) для управления календарями.
Я могу легко получить информацию о календаре, такую как календарьимена и списки календарей, но я не смог «записать» в календарь, например, добавить события или создать дополнительный календарь.Я всегда получаю следующую ошибку в моей попытке.
Кто-нибудь может помочь?Я посмотрел всюду в документации Google, но не могу найти ответы.
Ошибка (при попытке опубликовать, а не получить информацию):
Неустранимая ошибка: необнаруженное исключение «apiServiceException» с сообщением«Ошибка вызова POST https://www.googleapis.com/calendar/v3/calendars?key=eyfheufheuwehwi: (400) неверного значения» в /home/incs/google-api-php-client/src/io/apiREST.php:86 трассировке стека: # 0 / home / incs / google-api-php-client / src / io / apiREST.php (56): apiREST :: decodeHttpResponse (Object (apiHttpRequest)) # 1 /home/incs/google-api-php-client/src/service/apiServiceResource.php(187): apiREST :: execute (Object (apiServiceRequest)) # 2 /home/incs/google-api-php-client/src/contrib/apiCalendarService.php(228): apiServiceResource -> __ call ('insert', Array)) # 3 /home/public_html/gateway/google/index.php(130): CalendarsServiceResource-> insert (Object (Calendar)) # 4 {main}, брошенный в / home / incs / google-api-php-client / src/io/apiREST.php в строке 86
код (кстати, мои ключи доступа установлены в config.php, отсюда и закомментированные строки $ client)
<code>require("/home/incs/google-api-php-client/src/apiClient.php");
require("/home/incs/google-api-php-client/src/contrib/apiCalendarService.php");
session_start();
$client = new apiClient();
$client->setApplicationName("Google Calendar PHP Starter Application");
// Visit https://code.google.com/apis/console?api=calendar 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');
$service = new apiCalendarService($client);
if (isset($_GET['logout']))
{
unset($_SESSION['token']);
}
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())
{
$calendar = new Calendar();
$calendar->setSummary('calendarSummary');
$calendar->setTimeZone('American/Los_Angeles');
$createdCalendar = $service->calendars->insert($calendar);
$calList = $service->calendarList->listCalendarList();
print "<h1>Calendar List</h1><pre>" . print_r($calList, true) . "
";$ _SESSION ['token'] = $ client-> getAccessToken ();} else {$ authUrl = $ client-> createAuthUrl ();распечатать « Подключи меня! »;}