Google 캘린더에 이벤트 추가
-
21-12-2019 - |
문제
이 코드를 사용하여 내 캘린더에 이벤트를 추가
$client = new Google_Client();
$client->setApplicationName("Calendar");
$scopes = array('https://www.googleapis.com/auth/prediction', 'https://www.googleapis.com/auth/calendar');
$auth_credentials = new Google_Auth_AssertionCredentials(SERVICE_ACCOUNT_NAME, $scopes, $privateKey);
$client->setAssertionCredentials($auth_credentials);
$client->setClientId(CLIENT_ID);
$cal = new Google_Service_Calendar($client);
try {
$event = new Google_Service_Calendar_Event();
$event->setSummary('Halloween');
$event->setLocation('The Neighbourhood');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2014-01-09T10:00:00.000-05:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2014-01-10T10:25:00.000-05:00');
$event->setEnd($end);
$createdEvent = $cal->events->insert('primary', $event);
echo $createdEvent->getId()."\n\n";
}
catch (Exception $ex)
{
die($ex->getMessage());
}
.
이벤트 ID를 얻을 수 있지만 브라우저에서 캘린더를 볼 때 절대적으로 아무 것도 없습니다.
무엇을 잘못하고 있습니까?
해결책
캘린더를 자신에게 공유해야합니다.
이것은 새로운 Google_Client API를위한 것입니다.
$scope = new Google_Service_Calendar_AclRuleScope();
$scope->setType('user');
$scope->setValue( 'Your Email Goes Here' );
$rule = new Google_Service_Calendar_AclRule();
$rule->setRole( 'owner' );
$rule->setScope( $scope );
$result = $service->acl->insert('primary', $rule);
.
제휴하지 않습니다 StackOverflow