2016-09-29 3 views
3

PHP API를 사용하여 Google 캘린더를 업데이트하려고합니다. Google 캘린더 일정을 만들고 이벤트의 ID를 자동으로 가져올 수 있었지만 일정을 업데이트하려고 할 때 다음 오류가 발생합니다.Google 캘린더 업데이트 - 치명적 오류 : 정의되지 않은 함수 호출 dateTime()

PHP 치명적 오류 : public_html에서 dateTime() 정의되지 않은 함수를 호출하십시오. 여기

$event->setStart.dateTime($startdatetime); 

오류에 대한 내 현재 PHP 코드이다 : 그것은 라인을 참조한다 라인 45에 /googleapi/calendarupdate.php

<?php 

header('Content-type: application/json'); 

require_once __DIR__ . '/google-api-php-client/src/Google/autoload.php'; 

$summary = $_POST["summary"]; 
$location = $_POST["location"]; 
$description = $_POST["description"]; 
$startdatetime = $_POST["startdatetime"]; 
$enddatetime = $_POST["enddatetime"]; 
$clientemail = $_POST["clientemail"]; 
$privatekey = $_POST["privatekey"]; 
$useremail = $_POST["useremail"]; 
$calendarid = $_POST["calendarid"]; 



$client_email = $clientemail; 
$private_key = file_get_contents($privatekey); 
$scopes = array('https://www.googleapis.com/auth/calendar'); 
$user_to_impersonate = $useremail; 
$credentials = new Google_Auth_AssertionCredentials(
    $client_email, 
    $scopes, 
    $private_key, 
    'notasecret',         // Default P12 password 
    'http://oauth.net/grant_type/jwt/1.0/bearer', // Default grant type 
    $user_to_impersonate 
); 
$client = new Google_Client(); 
$client->setAssertionCredentials($credentials); 
if ($client->getAuth()->isAccessTokenExpired()) { 
    $client->getAuth()->refreshTokenWithAssertion(); 
} 

$service = new Google_Service_Calendar($client); 

$event = $service->events->get($useremail, $calendarid); 
$event->setSummary($summary); 
$event->setLocation($location); 
$event->setStart.dateTime($startdatetime); 
$event->setStart.timeZone('America/Los_Angeles'); 
$event->setEnd.dateTime($enddatetime); 
$event->setEnd.timeZone('America/Los_Angeles'); 
$event->setDescription($description); 

$updatedEvent = $service->events->update($useremail, $event->getId(), $event); 

echo json_encode($updatedEvent); 

내 PHP 코드는 구글의 API를 기반으로한다 문서 찾음 here.

+0

시작 날짜를 설정하면 날짜를 전달해야합니다. $ event-> setStart ($ date); – DaImTo

답변

0

좋아, 사실 그걸 알아 냈어. 이에

$event->setStart.dateTime($startdatetime); 

:

$event->start->setDateTime($startdatetime); 

내가 최종 날짜에 같은 일반적인 일을, 그것은, 난 그냥 넣어 말을 시작 말합니다 경우를 제외하고는 그냥 줄을 변경했다. 그냥 테스트 해봤는데 완벽하게 작동했습니다. 나를 도왔던 사이트는 here입니다.

관련 문제