【问题标题】:Creating a google calendar using php api使用 php api 创建谷歌日历
【发布时间】:2014-04-03 12:28:30
【问题描述】:

我想用php api创建一个google calendar,可以吗?

感谢您的帮助。

【问题讨论】:

    标签: php google-api google-calendar-api google-client


    【解决方案1】:

    是的,这是可能的!

    $url = 'http://www.googleapis.com/calendar/v3/calendars';
    $data = array(
        'summary' => 'MyNewCalendarTitle'
         );
    
    // use key 'http' even if you send the request to https://...
    $options = array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            'method'  => 'POST',
            'content' => http_build_query($data),
        ),
    );
    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    
    var_dump($result);
    

    code from this page

    link to doc for Calendar Insert


    但是使用Google API PHP client library 更容易

    $calendar = new Calendar();
    $calendar->setSummary('calendarSummary');
    $calendar->setTimeZone('America/Los_Angeles');
    
    $createdCalendar = $service->calendars->insert($calendar)
    

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 2021-02-08
      相关资源
      最近更新 更多