2014-04-03 84 views

回答

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