Timezone is missing
Hello,
Is there any way to get the timezone. I and using google calendar and I want the time zone when we access the token.
Thanks,
It might be available in $user->toArray().
If you can point me to the documentation that shows where the timezone information would be made available?
I use to like this and it's working
public function GetUserCalendarTimezone($access_token) { $url_settings = 'https://www.googleapis.com/calendar/v3/users/me/settings/timezone';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_settings);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '. $access_token));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = json_decode(curl_exec($ch), true); //echo '<pre>';print_r($data);echo '</pre>';
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
if($http_code != 200)
throw new Exception('Error : Failed to get timezone');
return $data['value'];
}
That looks like a perfect solution for your need!
Including such code in this package could be useful, as a separate piece of functionality. I would welcome a PR for it.