[kronolith] Howto use the kronolith API
Michael J Rubinsky
mrubinsk at horde.org
Sat Feb 6 17:20:19 UTC 2021
Quoting Ferdinand Gruber <fer.grub at yahoo.de>:
> Hi,
>
> please can anyone give me a simple example how to use the kronolith
> API in my own PHP project.
>
> I have been using the script kronolith-import-icals.php in a PHP
> project for a long time to import events from a separate form into
> my kronolith calendar.
>
> This is what the ICS file looks like that I am currently using
>
> $ical =
> "BEGIN:VCALENDAR".$eol.
> "VERSION:2.0".$eol.
> "BEGIN:VEVENT".$eol.
> "DTSTART;TZID=Europe/Vienna:".$event_start.$eol.
> "DTEND;TZID=Europe/Vienna:".$event_end.$eol.
> "DTSTAMP:".time().$eol.
> "UID:".$event_uid.$eol.
> "SUMMARY:".$event_title.$eol.
> "DESCRIPTION:".str_replace("\r\n", "\\n", $event_description).$eol.
> "LOCATION:".$event_location.$eol.
> "CLASS:PUBLIC".$eol.
> "END:VEVENT".$eol.
> "END:VCALENDAR".$eol;
>
> The variables are generated from$_POST.
>
> I use to this script with PHP in this way:
>
> $output = shell_exec("php
> /srv/www/htdocs/horde/kronolith/bin/_kronolith-import-icals.php
> '".$calendar_id."' '".$user."' '".$pw."' '".$ical."'");
>
> This way I am able to write data into the kronolith Calendar. But I
> suppose that this is not really a good approach ...
>
> How can I write data into my kronolith calendar using the kronolith API?
That depends on how you want to access the API. If you are on the same
machine as the horde instance, you can interact with the API using the
horde Registry object, just like the kronolith-import-icals.php script
does. If you want to interact with it over HTTPS, you would use the
JSON-RPC interface. The methods supported by kronolith can be found
here:
https://dev.horde.org/api/master/app/kronolith/classes/Kronolith_Api.html
To import a event, you would want the `import` method. So, to import
an event, you would POST to https://$horde_base/rpc/ passing the horde
credentials of the account you want to import to via Basic Auth and
post a json-rpc object e.g,
{
'method': 'kronolith.import',
'params': {
'contentType': 'text/calendar',
'content': $iCal,
'calendar': $calendarId
}
}
I'm not sure why this would be better than using the import script you
are already using, as this essentially results in the same actions.
> Some little hints would help me.
>
> Many thanks in advance.
>
> --
> Regards from Austria
> Ferdinand Gruber
>
> --
> kronolith mailing list
> Frequently Asked Questions: http://wiki.horde.org/FAQ
> To unsubscribe, mail: kronolith-unsubscribe at lists.horde.org
--
mike
The Horde Project
http://www.horde.org
https://www.facebook.com/hordeproject
https://www.twitter.com/hordeproject
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-keys
Size: 9272 bytes
Desc: PGP Public Key
URL: <https://lists.horde.org/archives/kronolith/attachments/20210206/9017ee7c/attachment-0001.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 851 bytes
Desc: PGP Digital Signature
URL: <https://lists.horde.org/archives/kronolith/attachments/20210206/9017ee7c/attachment-0001.sig>
More information about the kronolith
mailing list