\documentclass{article}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{headings}
\begin{document}
\part{Using XML/RPC to interface with the Horde API using Python}
You can easily use Python to communicate with Horde through XML/RPC. Recent versions of Python have a built-in library "xmlrpclib" which even supports SSL (the "<a href="https://">https://</a>" protocol) and authentication! Below you find an example which accesses Kronolith's API to enumerate and download calendars. You can do similar things with other Horde modules.

Look at the \textit{modulename/lib/api.php} files in the Horde distribution to see which APIs you can use.

Note regarding SOAP: it is also possible to communicate with Horde's SOAP API using the Python library "SOAPpy", but SOAP doesn't offer any inherent advantages over XML-RPC when dealing with Horde's API.

<pre><code class="language-python">
\# 
\# Horde XML-RPC with Python Example
\#
\# This is a simple example which shows how to communicate with Horde through
\# the XML-RPC interface using the Python programming language.
\#
\# It enumerates all calendars a user has read access to and saves them to
\# the harddisk as VCALENDAR files for backup purposes.
\#

import xmlrpclib

\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# User settings \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#

\# The user name on the Horde server.
\# When using imp authentication, always use the \_full\_ email address here!
\# When using SQL authentication, just use your login name
username = "joe.user@my-server.com"
\# username = "joe.user"

\# The password of this Horde user
password = "secret"

\# Protocol to use for connection ("http" or "https")
protocol = "https"

\# Server host name (and directory, if needed)
hostname = "horde.my-server.com"
\# hostname = "www.my-server.com/horde"

\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# End of settings \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#

url = "\%s://\%s:\%s@\%s/rpc.php" \% (protocol, username, password, hostname)

print "Connecting to URL '\%s'..." \% url
server = xmlrpclib.ServerProxy(url, verbose=0)

print "Retrieving list of calendars..."

calendars = server.calendar.listCalendars(False, 4) \# "read permission"

for calendarKey in calendars:
    print "Downloading calendar \%s..." \% calendarKey

    content = server.calendar.exportCalendar(calendarKey, "text/calendar")

    filename = calendarKey + ".ics"

    print "Writing file '\%s'..." \% filename

    f = file(filename, "wt")
    f.write(content.encode('utf-8'))
    f.close()

print "Done."
</code></pre>
\end{document}
