2014-03-25 1 views
-1

그래서 Google 캘린더를 작동시키는 방법을 알아 내려고 몇 시간을 보냈습니다. V3에는 달력 예제가 없기 때문에 simple.php 예가있는 이전 자식을 찾은 것 같습니다. 고객 ID, 비밀번호, 리디렉션 및 API 키를 입력했습니다.v3에서도 작동합니까? No Documentation

나는 simple.php 페이지를 탐색하고 인증을 요청하고, 다시 리디렉션하며, 캘린더 목록을 보여줍니다.이 목록은 내 캘린더와 전혀 관련이없는 무작위로 구성된 일련의 배열입니다.

어떻게 이것을 실제 캘린더에 표시 할 수 있습니까? 이것에 대한 문서가없는 이유는 무엇입니까?

나는 단순히 로그인 한 사용자의 웹 페이지에 표시 할 수있는 Google 캘린더를 얻으려고합니다.이 같은 문서를 많이 읽었을 것입니다. Google api를 사용하여이 기능을 사용할 수 있습니까? 저를 얻을 수

<?php 
require_once '../../src/Google_Client.php'; 
require_once '../../src/contrib/Google_CalendarService.php'; 
session_start(); 

$client = new Google_Client(); 
$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('myClientId'); 
$client->setClientSecret('myClientSecret'); 
$client->setRedirectUri('http://localhost/wordpress/wp-content/themes/twentyfourteen/google-api-php-client/examples/calendar/simple.php'); 
$client->setDeveloperKey('myApiKey'); 
$cal = new Google_CalendarService($client); 
if (isset($_GET['logout'])) { 
    unset($_SESSION['token']); 
} 

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()) { 
    $calList = $cal->calendarList->listCalendarList(); 
    print "<h1>Calendar List</h1><pre>" . print_r($calList, true) . "</pre>"; 

    $calendar = $service->calendars->get('primary'); 
    echo $calendar->getSummary(); 


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

Calendar List 
Array 
(
    [kind] => calendar#calendarList 
    [etag] => "uz4dSMPAwpogj1sIr_PP7Gm-AxY/Dkoq7AkW5RQPry2qgnRZSo6dywQ" 
    [items] => Array 
     (
     [0] => Array 
      (
       [kind] => calendar#calendarListEntry 
       [etag] => "uz4dSMPAwpogj1sIr_PP7Gm-AxY/OfDIPQtOizBQ0xUM55cH-RiMGw4" 
       [id] => myEmailAddress 
       [summary] => myEmailAddress 
       [timeZone] => America/Los_Angeles 
       [colorId] => 15 
       [backgroundColor] => #9fc6e7 
       [foregroundColor] => #000000 
       [selected] => 1 
       [accessRole] => owner 
       [defaultReminders] => Array 
        (
         [0] => Array 
          (
           [method] => email 
           [minutes] => 10 
          ) 

         [1] => Array 
          (
           [method] => popup 
           [minutes] => 30 
          ) 

        ) 

       [notificationSettings] => Array 
        (
         [notifications] => Array 
          (
           [0] => Array 
            (
             [type] => eventCreation 
             [method] => email 
            ) 

           [1] => Array 
            (
             [type] => eventChange 
             [method] => email 
            ) 

           [2] => Array 
            (
             [type] => eventCancellation 
             [method] => email 
            ) 

           [3] => Array 
            (
             [type] => eventResponse 
             [method] => email 
            ) 

          ) 

        ) 

       [primary] => 1 
      ) 

     [1] => Array 
      (
       [kind] => calendar#calendarListEntry 
       [etag] => "uz4dSMPAwpogj1sIr_PP7Gm-AxY/sjFVOlVft6ECLQqbceDo4SWExfc" 
       [id] => #[email protected] 
       [summary] => Contacts' birthdays and events 
       [description] => Your contacts' birthdays and anniversaries 
       [timeZone] => America/Los_Angeles 
       [colorId] => 17 
       [backgroundColor] => #9a9cff 
       [foregroundColor] => #000000 
       [selected] => 1 
       [accessRole] => reader 
      ) 

     [2] => Array 
      (
       [kind] => calendar#calendarListEntry 
       [etag] => "uz4dSMPAwpogj1sIr_PP7Gm-AxY/R5Pe_cDz8Mqz0fmwnfeci-di2wo" 
       [id] => en.usa#[email protected] 
       [summary] => Holidays in United States 
       [description] => Holidays in United States 
       [timeZone] => America/Los_Angeles 
       [colorId] => 9 
       [backgroundColor] => #7bd148 
       [foregroundColor] => #000000 
       [selected] => 1 
       [accessRole] => reader 
      ) 

    ) 

) 
Notice: Undefined variable: service in C:\xampp\htdocs\wordpress\wp-content\themes\twentyfourteen\google-api-php-client\examples\calendar\simple.php on line 33 

Notice: Trying to get property of non-object in C:\xampp\htdocs\wordpress\wp-content\themes\twentyfourteen\google-api-php-client\examples\calendar\simple.php on line 33 

Fatal error: Call to a member function get() on a non-object in C:\xampp\htdocs\wordpress\wp-content\themes\twentyfourteen\google-api-php-client\examples\calendar\simple.php on line 33 
+0

왜 누군가 투표를해야 할 필요가 있는지 확신 할 수 없습니다. 문서를 찾는 유일한 사람이 아니에요. – Bowenac

+0

여기에 코드 샘플, tos 및 API 참조 https://developers.google.com/google-apps/calendar –

+0

을 포함하여 google 캘린더 API 문서가 포함되어 있습니다. 질문을 명확히하기 위해 Google 캘린더를 퍼가려고합니까? 다른 웹 페이지? 그렇다면 https://support.google.com/calendar/answer/41207 –

답변