2012-04-02 1 views
1

Google 캘린더 API 버전 3 (PHP)을 사용하여 캘린더를 관리하려고합니다.Google 캘린더 API v3 PHP가 캘린더에 게시 할 때이 오류를 던지는 이유는 무엇입니까?

나는 쉽게 는 일정 이름 및 일정 목록과 같은 일정에 관한 정보를 검색 할 수 있습니다, 그러나 나는 이러한 이벤트를 추가하거나 보조 달력을 만들기로 달력에 실제로 '서면'에 실패 을입니다. 내 시도에서 항상 다음과 같은 오류가 발생합니다.

도움이 될만한 사람이 있습니까? Google 문서에서 어디서나 보았지만 답변을 찾을 수 없습니다.

오류 (게시하려고하는 경우가 아닌 정보를 검색) :

치명적인 오류 : 메시지 catch되지 않은 예외 'apiServiceException' 'POST https://www.googleapis.com/calendar/v3/calendars?key=eyfheufheuwehwi 호출 오류 : (400) 잘못된 값'/ 홈/incs/구글에 -api-php-client/src/io/apiREST.php : 86 스택 추적 : # 0 /home/incs/google-api-php-client/src/io/apiREST.php(56) : apiREST :: decodeHttpResponse ((apiHttpRequest)) # 1 /home/incs/google-api-php-client/src/service/apiServiceResource.php(187) : apiREST :: execute (Object (apiServiceRequest)) # 2/home/incs/google-/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-a에 던졌습니다. PI-PHP 클라이언트/SRC/IO/apiREST.php 라인 (86)

(내 액세스 키가 config.php를 설정하는 방법에 의해 따라서 주석 $ 클라이언트 라인) 코드

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) . "</pre>"; 


    $_SESSION['token'] = $client->getAccessToken(); 
} 
else 
{ 
    $authUrl = $client->createAuthUrl(); 
    print "<a class='login' href='$authUrl'>Connect Me!</a>"; 
} 

답변

4

지금 당장 Google은 코드 샘플에 오류가 있습니다 (여기에 내가 붙여 넣은 코드가 있습니다). 이 샘플에서는 다음과 같은 요구가 작동하려면 수정합니다 :

$calendar->setTimeZone('American/Los_Angeles'); 

$calendar->setTimeZone('America/Los_Angeles'); 

로 수정 될 그리고 오류가 발생되지 않습니다해야합니다.

+0

보고서 주셔서 감사합니다, 그것은 문서에 수정되었습니다! – Alain

+0

@Alain 여러분을 환영합니다. V3는 위대한 thx 작품! – flukyspore