これはお尻のような巨大な痛みですが、私は最終的に少なくともイベントを作成するために働いています。
最新のGoogle PHP APIジップをダウンロードして、ウェブサーバーのインクルードフォルダにアップロードします。 Google APIコンソールを使用してAPIクライアントを設定します。あなたのリダイレクトURLを自分のページのURLと同じに設定することを忘れないでください。そうすれば、自分自身にリダイレクトされます。
イベントの詳細にはいくつかの変数を設定していますが、必要に応じてこれらを押し込むフォームを作成できます。リンクの下の
<?php
$jobname = "BINGO";
$joblocation = "Your mums house";
$jobdescription = "An interview with a dog.";
$startofjob = "2013-12-20T17:00:00.000+00:00"; //datetimes must be in this format
$endofjob = "2013-12-20T18:00:00.000+00:00"; // YYYY-MM-DDTHH:MM:SS.MMM+HH:MM
//So that's year, month, day, the letter T, hours, minutes, seconds, miliseconds, + or -, timezoneoffset in hours and minutes
include('google-api-php-client/src/Google_Client.php');
include('google-api-php-client/src/contrib/Google_CalendarService.php');
session_start();
$client = new Google_Client();
$client->setApplicationName('doesntmatter-whateveryouwant');
$client->setClientId('yourclientid');
$client->setClientSecret('yourclientsecret');
$client->setRedirectUri('yourredirecturl-setingoogleconsole');
$client->setDeveloperKey('yourdeveloperkey');
$cal = new Google_CalendarService($client);
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if ($client->getAccessToken()) {
$event = new Google_Event();
$event->setSummary($jobname);
$event->setDescription($jobdescription);
$event->setLocation($joblocation);
$start = new Google_EventDateTime();
$start->setDateTime($startofjob);
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime($endofjob);
$event->setEnd($end);
$createdEvent = $cal->events->insert('[email protected]', $event);
echo $createdEvent->id;
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Connect Me!</a>";
}
?>
フォロー:
は、ここに私のコードです。 https://stackoverflow.com/questions/43658751/add-events-to-calendar-programmatically?answertab=votes#tab-top –
以下のリンクに従ってください。 https://stackoverflow.com/questions/43658751/add-events-to-calendar-programmatically?answertab=votes#tab-top –