Google Calendar APIv3 sample - update event not working

Hello,

I have been trying to establish two way synchronization with Google Calendar for a sample dhtmlxScheduler component.

I have followed your guide and downloaded the sample code from:
docs.dhtmlx.com/scheduler/google … ation.html

I have successfully established the connection and inserting and deleting events is working fine. However, when I try to update an existing event, the event text is successfully updated in my Google Calendar account, but the start_date and the end_date cannot be changed.

I have tried adding a data processor “onBeforeUpdate” event, that alters the date format to match the format expected by Goolgle APIs, but it did not help.

I honestly don’t know what might be the problem. Any help would be greatly appreciated!

Thank you!

Hello,
are you using a latest version of the a proxy script for google calendar google_proxy.php?
There was a similar issue that has been fixed in a while, so now everything should work correctly
github.com/DHTMLX/scheduler-goo … dar/pull/1
So please confirm whether the issue happens with the latest version of scheduler-google-calendar codebase from the github

Hi Aliaksandr,

Indeed I was using the old version of google_proxy.php, however the problem persisted even with the code you suggested. I managed to get it working with the following additions:

[code] private function updateEvent($ev, $data){
$data[“start”] = array(
“dateTime” => $this->to_gDate($data[“start_date”]),
“timeZone” => “Europe/Copenhagen” );
$ev[“start”] = array(
“dateTime” => $this->to_gDate($data[“start_date”]),
“timeZone” => “Europe/Copenhagen” );
$data[“end”] = array(
“dateTime” => $this->to_gDate($data[“end_date”]),
“timeZone” => “Europe/Copenhagen” );
$ev[“end”] = array(
“dateTime” => $this->to_gDate($data[“end_date”]),
“timeZone” => “Europe/Copenhagen” );

  •   $ev["summary"] = $data["text"];
    
  •   $data["summary"] = $data["text"];
    
      try{
    
  •   	$ev = $this->cal->events->update($this->cal_name, $ev["id"], new Google_Event($ev));
    
  •   	$ev = $this->cal->events->update($this->cal_name, $ev["id"], new Google_Event($data));
      } catch(Exception $error){
      	return false;
      }
    
      // process response
      if ($ev)
      	return $ev["id"];
      return false;
    
    }[/code]

It is updating the events successfully now.

I have another question - is there a way to detect client’s time zone automatically, because it is currently set to “Europe/Minsk” in google_proxy.php and the events are created and updated with a time offset for me. (It works ok when I manually change the time zone.)

thanks

thanks for the update.

I’m not sure there will be a generic way for detecting client’s timezone, but we’ll add a public property for setting in programmatically instead of hardcoded values

great, thanks! Could you post some further info here, when it is done?

Hi,
we’ve updated the plugin
github.com/DHTMLX/scheduler-google-calendar
you can set the timezone using timezone property of GoogleCalendarProxy class.
If you set it to false or null, it should take a timezone from a google calendar:

$calendar = new GoogleCalendarProxy( ... ); $calendar->timezone = false; $calendar->connect();

Thanks a lot for the update. Works great!