PHP Extension Google Calendar: Update (Patch) a Calendar Entry

Back to Index

Updates an entry on the user's calendar list.
This example updates the "summary" for the calendar having the ID = "". The new summary will be "Party Calendar".



// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:

$rest = new CkRest();

//   Provide a previously obtained OAuth2 access token.
$oauth2 = new CkOAuth2();

$success = $rest->Connect('',443,true,true);
if ($success != true) {
    print $rest->lastErrorText() . "\n";

//  The following code creates the JSON request body.
//  The JSON created by this code is shown below.
$jsonReq = new CkJsonObject();
$jsonReq->UpdateString('summary','Party Calendar');

$sbReq = new CkStringBuilder();


$sbJson = new CkStringBuilder();
$success = $rest->FullRequestSb('PATCH','/calendar/v3/calendars/',$sbReq,$sbJson);
if ($success != true) {
    print $rest->lastErrorText() . "\n";

if ($rest->get_ResponseStatusCode() != 200) {
    print 'Received error response code: ' . $rest->get_ResponseStatusCode() . "\n";
    print 'Response body:' . "\n";
    print $sbJson->getAsString() . "\n";

$json = new CkJsonObject();

//  The following code parses the JSON response.
//  A sample JSON response is shown below the sample code.

$kind = $json->stringOf('kind');
$etag = $json->stringOf('etag');
$id = $json->stringOf('id');
$summary = $json->stringOf('summary');
$timeZone = $json->stringOf('timeZone');

print 'Example Completed.' . "\n";


Sample JSON Request Body

"summary": "Party Calendar" 


Sample JSON Response Body

  "kind": "calendar#calendar",
  "etag": "\"BKjXnZpXR6E5ueFWG3UJk-2POYg/jcCkAVFAjoCovUbrUQlnks64qfY\"",
  "id": "",
  "summary": "Party Calendar",
  "timeZone": "UTC"