I’m running into an issue which I can’t fix and can’t even understand: I’m using the Google Calendar Plugin for Kirby and it breaks when it tries to get the DateTime of an event. Pretty strange since I can access every other key in the JSON except this one.
The author of the plugin seems to be gone so my hope is this forum.
and the part where the dateTime key seem to be parsed looks like this:
$events[$i] += ["datestart" => new DateTime(DateTime::createFromFormat("Y-m-d?H:i:sP", $event['start']['dateTime'])->format(option('benediktengel.google-calendar-plugin.formatDate')))];
Pretty normal to me but it won’t access the array. I tried everything, even creating a new JSON Parse to just access this array but it still won’t work.
If you have any hint for me, I would be super happy!
I don’t know. I tried to access another key written in camelcase and got the same error.
Your snippet now throws this:
ParseError thrown with message “syntax error, unexpected ‘->’ (T_OBJECT_OPERATOR)”
Stacktrace:
#14 ParseError in /Applications/MAMP/htdocs/chiemgauermuenchen2021/site/plugins/google-calendar-plugin/snippets/calendar.php:58
#13 Kirby\Toolkit\F:loadIsolated in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/F.php:380
#12 Kirby\Toolkit\F:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/Tpl.php:35
#11 Kirby\Toolkit\Tpl:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/config/components.php:288
#10 Kirby\Cms\App:{closure} in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/App.php:1390
#9 Kirby\Cms\App:snippet in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/config/helpers.php:674
#8 snippet in /Applications/MAMP/htdocs/chiemgauermuenchen2021/site/templates/termine.php:7
#7 include in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/F.php:403
#6 Kirby\Toolkit\F:loadIsolated in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/F.php:380
#5 Kirby\Toolkit\F:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/Tpl.php:35
#4 Kirby\Toolkit\Tpl:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/Template.php:167
#3 Kirby\Cms\Template:render in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/Page.php:1172
#2 Kirby\Cms\Page:render in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/App.php:686
#1 Kirby\Cms\App:io in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/App.php:1039
#0 Kirby\Cms\App:render in /Applications/MAMP/htdocs/chiemgauermuenchen2021/index.php:5
Oh wow, you’re so quick! Thanks.
Looks way better, but something is still wrong. I don’t know if it can access the dateTime from JSON now. Because:
TypeError thrown with message "DateTime::__construct() expects parameter 1 to be string, object given"
Stacktrace:
#16 TypeError in /Applications/MAMP/htdocs/chiemgauermuenchen2021/site/plugins/google-calendar-plugin/snippets/calendar.php:50
#15 DateTime:__construct in /Applications/MAMP/htdocs/chiemgauermuenchen2021/site/plugins/google-calendar-plugin/snippets/calendar.php:50
#14 include in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/F.php:403
#13 Kirby\Toolkit\F:loadIsolated in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/F.php:380
#12 Kirby\Toolkit\F:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/Tpl.php:35
#11 Kirby\Toolkit\Tpl:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/config/components.php:288
#10 Kirby\Cms\App:{closure} in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/App.php:1390
#9 Kirby\Cms\App:snippet in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/config/helpers.php:674
#8 snippet in /Applications/MAMP/htdocs/chiemgauermuenchen2021/site/templates/termine.php:7
#7 include in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/F.php:403
#6 Kirby\Toolkit\F:loadIsolated in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/F.php:380
#5 Kirby\Toolkit\F:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Toolkit/Tpl.php:35
#4 Kirby\Toolkit\Tpl:load in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/Template.php:167
#3 Kirby\Cms\Template:render in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/Page.php:1172
#2 Kirby\Cms\Page:render in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/App.php:686
#1 Kirby\Cms\App:io in /Applications/MAMP/htdocs/chiemgauermuenchen2021/kirby/src/Cms/App.php:1039
#0 Kirby\Cms\App:render in /Applications/MAMP/htdocs/chiemgauermuenchen2021/index.php:5
Somehow all keys work except those written in camelCase
So if I try to get the email in creator it works. But if I try to get displayName it breaks.
This is just an example, I never used it inside my code.
Oh, if I limit the results to 30, it seems to work. It’s not displaying anything since all the events are in the past and the plugin only displays upcoming stuff but maybe there is something empty.
If you decide to create an event on Google Calendar which is without a time, so just the date, the key is date and if you edit the event and decide to let it start at 6AM, it converts the date to dateTime