0

Google 캘린더와 상호 작용하는 앱을 만들고 리소스를보고 싶지만 시청을 중지 할 수도 있습니다. 내가 않은 시계에 때Google 캘린더 API - 이벤트보기 중지

나는 나 자신을 인증하는 서비스 계정과의 OAuth 2.0을 사용하여 절대적 그래서 내가있는 권한 알고 찾을 작업 다른 API 호출을하고 Error calling POST https://www.googleapis.com/calendar/v3/channels/stop: (403) Incorrect OAuth client

오류를 얻을. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

이러한 작업 API 호출의 일부가된다 ...

public function getEvents($calendarId, $opts = array()) 
{ 
    $events = $this->calendarService->events->listEvents($calendarId, $opts); 
    return $events; 
} 

public function getEvent($calendarId, $eventId) 
{ 
    $event = $this->calendarService->events->get($calendarId, $eventId); 
    return $event; 
} 

public function watch($calendarId, $channelId, $listener) 
{ 
    $channel = new Google_Service_Calendar_Channel($this->client); 
    $channel->setId($channelId); 
    $channel->setType('web_hook'); 
    $channel->setAddress($listener); 

    $watchEvent = $this->calendarService->events->watch($calendarId, $channel, array()); 
    return $watchEvent; 
} 

이것은 정지 API 호출 ...

public function stopWatch($channelId, $resourceId) 
{ 
    $channel = new Google_Service_Calendar_Channel($this->client); 
    $channel->setId($channelId); 
    $channel->setResourceId($resourceId); 

    $watchEvent = $this->calendarService->channels->stop($channel); 
    return $watchEvent; 
} 

이 작업을하는 방법에 어떤 아이디어가?

답변

0

클라이언트의 서비스를 인스턴스화 한 다음 서비스의 채널을 인스턴스화해야합니다. 바로 가기가있을 수 있지만 아래 코드는 작동합니다.

$service = new Google_Service_Calendar($client); 
$channel = new Google_Service_Calendar_Channel($service); 
$channel->setId($channelID); 
$channel->setResourceId($ResourceID); 

try 
{ 
    $service->channels->stop($channel); 
} 
catch(Exception $e) 
{ 
    error_log("Caught exception in killWatch ",0); 
}