{"id":7254,"date":"2020-02-18T15:10:50","date_gmt":"2020-02-18T13:10:50","guid":{"rendered":"https:\/\/churchtools.academy\/?post_type=docs&#038;p=7254"},"modified":"2026-01-13T12:10:35","modified_gmt":"2026-01-13T11:10:35","password":"","slug":"api-alt","status":"publish","type":"docs","link":"https:\/\/churchtools.academy\/de\/help\/system-einstellungen\/api\/api-alt\/","title":{"rendered":"API-Alt"},"content":{"rendered":"\n<aside class=\"wp-block-group ct-box ct-box-blue has-text-color has-background has-link-color wp-elements-74648fa9a9506de5179716347194bc98 is-vertical is-layout-flex wp-container-core-group-is-layout-002f1c27 wp-block-group-is-layout-flex\" style=\"border-radius:8px;border-left-color:#e7c000;border-left-width:0.5rem;color:#3f3400;background-color:#ffe5644d;margin-top:var(--wp--preset--spacing--60);margin-bottom:var(--wp--preset--spacing--60)\">\n<p style=\"margin-top:0.5rem;margin-right:0.5rem;margin-bottom:0rem;margin-left:0.5rem\"><strong>Wichtig<\/strong><\/p>\n\n\n\n<p style=\"margin-top:0rem;margin-right:0.5rem;margin-bottom:0.5rem;margin-left:0.5rem\">Diese Seite beschreibt die alte AJAX-API in ChurchTools. Informationen \u00fcber die neue RESTful-API findest du auf der Seite <a href=\"https:\/\/churchtools.academy\/help\/system-einstellungen\/api\/0-api\/\" data-type=\"link\" data-id=\"https:\/\/churchtools.academy\/help\/system-einstellungen\/api\/0-api\/\">API<\/a>.<\/p>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Funktionsweise der API<\/h2>\n\n\n\n<p>Da ChurchTools die gesamte Kommunikation&nbsp;\u00fcber AJAX steuert, kann jede Funktion auch \u00fcber API aufgerufen werden.<\/p>\n\n\n\n<p>Also z. B.&nbsp;<a href=\"https:\/\/xxx.churchtools.de\/index.php?q=churchresource\/ajax\">https:\/\/xxx.churchtools.de\/index.php?q=churchresource\/ajax<\/a><\/p>\n\n\n\n<p>Und per POST dann:<em>&nbsp;func=getBookings<\/em> (liefert alle Buchungen) oder z. B.&nbsp;<em>func=getMasterData <\/em>liefert alle notwendigen Stammdaten.<\/p>\n\n\n\n<p>Wichtig ist, dass der Aufruf \u00fcber POST-Befehl gesendet wird und die gew\u00fcnschte Funktion in dem Parameter &#8222;func=functioname&#8220; enthalten ist. Pro Modul gibt es verschiedene Aufrufe. Hierzu kann unter system\/modulename\/classes\/CTModulename.class.php nachgeschaut werden.&nbsp;&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Weitere Beispiele f\u00fcr API-Calls<\/h2>\n\n\n\n<p>Also z. B. Login \u00fcber<\/p>\n\n\n\n<p><a href=\"https:\/\/xxx.churchtools.de\/?q=login\"><code>https:\/\/xxx.churchtools.de\/?q=login<\/code><\/a><\/p>\n\n\n\n<p>Per POST dann die Parameter:<\/p>\n\n\n\n<p>email<\/p>\n\n\n\n<p>password<\/p>\n\n\n\n<p>directtool=yes<\/p>\n\n\n\n<p><strong>Abfrage von allen Personen<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/xxx.churchtools.de\/?q=churchdb\/ajax&amp;func=getAllPersonData\"><code>https:\/\/xxx.churchtools.de\/?q=churchdb\/ajax&amp;func=getAllPersonData<\/code><\/a><\/p>\n\n\n\n<p><strong>Abfrage einer Person<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/xxx.churchtools.de\/?q=churchdb\/ajax&amp;func=getPersonDetails&amp;id=736\"><code>https:\/\/xxx.churchtools.de\/?q=churchdb\/ajax&amp;func=getPersonDetails&amp;id=736<\/code><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Beispiel&nbsp;eines API-Calls in PHP<\/h2>\n\n\n\n<p><code>&lt;?php <\/code><br><code>\/** * Example API call to ChurchTools Installation for PHP. The cookies will be stored to current directory <\/code><br><code>* Author: Jens Martin Rauen <\/code><br><code>* Copyright: 2015 <\/code><br><code>**\/ <\/code><\/p>\n\n\n\n<p><code>\/** &nbsp;<\/code><br><code>* Get saved Cookies from filesystem and returns an array &nbsp;<\/code><br><code>* @return array of Cookies in string &nbsp;<\/code><br><code>*\/ <\/code><br><code>function getCookies() {<\/code><br><code> &nbsp; $aCookies = glob(\"*.txt\");<\/code><br><code> &nbsp; $n = count($aCookies);<\/code><br><code> &nbsp; if ($n !== 0) {<\/code><br><code> &nbsp; &nbsp;$counter = 0;<\/code><\/p>\n\n\n\n<p><code> &nbsp; while ($counter &lt; $n) {<\/code><br><code> &nbsp; &nbsp; $sCombined .= file_get_contents($aCookies[\"$counter\"]) . ';';<\/code><br><code> &nbsp; &nbsp; ++$counter;<\/code><br><code> &nbsp; &nbsp;}<\/code><br><code> &nbsp; &nbsp;return $sCombined;<\/code><br><code> &nbsp; } else {<\/code><br><code> &nbsp; &nbsp;return $n;<\/code><br><code> &nbsp; }<\/code><br><code>} <\/code><\/p>\n\n\n\n<p><code>\/**<\/code> <br><code>&nbsp;* Save cookies from $aRH (http response header) to the filesystem <\/code><br><code>&nbsp;* @param $aRH <\/code><br><code>&nbsp;*\/ <\/code><br><code>function saveCookies($aRH) {<\/code><br><code> &nbsp; $n = count($aRH); \/\/ Number of Pieces<\/code><br><code> &nbsp; $counter = 0;<\/code><br><code> &nbsp; while ($counter &lt;= $n) {<\/code><br><code> &nbsp; &nbsp; if(preg_match('@Set-Cookie: (([^=]+)=[^;]+)@i', $aRH[\"$counter\"], $matches)) {<\/code><br><code> &nbsp; &nbsp; &nbsp; $fp = fopen($matches[\"2\"].'.txt', 'w');<\/code><br><code> &nbsp; &nbsp; &nbsp; &nbsp;fwrite($fp, $matches[\"1\"]);<\/code><br><code> &nbsp; &nbsp; &nbsp; fclose($fp);<\/code><br><code> &nbsp; &nbsp; }<\/code><br><code> &nbsp; &nbsp; ++$counter;<\/code><br><code> &nbsp; }<\/code> <br><code>} <\/code><\/p>\n\n\n\n<p><code>\/** <\/code><br> <code>* Send request to $url with $data <\/code><br><code>&nbsp;* @param [type] $url &nbsp;[description] <\/code><br><code>&nbsp;* @param [type] $data [description] <\/code><br><code>&nbsp;*\/ <\/code><br><code>function sendRequest($url, $data) {<\/code><br><code> &nbsp; $options1 = array(<\/code><br><code> &nbsp; &nbsp; 'http' =&gt; array(<\/code><br><code> &nbsp; &nbsp; &nbsp; 'header' &nbsp;=&gt; \"Cookie: \".getCookies() . \"rnContent-type: application\/x-www-form-urlencodedrn\",<\/code><br><code> &nbsp; &nbsp; &nbsp; 'method' &nbsp;=&gt; 'POST',<\/code><br><code> &nbsp; &nbsp; &nbsp; 'content' =&gt; http_build_query($data),<\/code><br><code> &nbsp; &nbsp; ),<\/code><br><code> &nbsp; );<\/code><br><code> &nbsp; $context &nbsp;= stream_context_create($options1);<\/code><br><code> &nbsp; $result = file_get_contents($url, false, $context);<\/code><br><code> &nbsp; print_r($result);<\/code><br><code> &nbsp; saveCookies($http_response_header); <\/code><br><code>} <\/code><\/p>\n\n\n\n<p><code>\/\/ Login to mghh churchtools <\/code><br><code>$url = 'https:\/\/mghh.churchtools.de\/?q=login'; <\/code><br><code>$data = array('email' =&gt; 'sabine@mghh.churchtools.de', 'password' =&gt; '1234', <\/code><br><code>'directtool' =&gt; 'yes'); <\/code><br><code>sendRequest($url, $data); <\/code><\/p>\n\n\n\n<p><code>\/\/ Now get all Person data <\/code><br><code>$url = 'https:\/\/mghh.churchtools.de\/index.php?q=churchdb\/ajax'; <\/code><br><code>$data = array('func' =&gt; 'getAllPersonData'); <\/code><br><code>sendRequest($url, $data);<\/code><\/p>\n\n\n\n<aside class=\"wp-block-group ct-artikel-zum-weiterlesen has-background is-layout-constrained wp-container-core-group-is-layout-89fd719a wp-block-group-is-layout-constrained\" style=\"border-radius:8px;background-color:#f9fafb;margin-top:24px;margin-bottom:24px;padding-top:32px;padding-right:24px;padding-bottom:32px;padding-left:24px\">\n<h2 class=\"wp-block-heading has-medium-font-size\">Artikel zum Weiterlesen<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/churchtools.academy\/de\/help\/system-einstellungen\/api\/0-api\/\" data-type=\"docs\" data-id=\"7251\">\u00dcberblick API<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/churchtools.academy\/de\/help\/system-einstellungen\/api\/0-api-authentifizierung\/\" data-type=\"docs\" data-id=\"7252\">API Authentifizierung<\/a><\/li>\n<\/ul>\n<\/aside>\n","protected":false},"excerpt":{"rendered":"<p>Funktionsweise der API Da ChurchTools die gesamte Kommunikation&nbsp;\u00fcber AJAX steuert, kann jede Funktion auch \u00fcber API aufgerufen werden. Also z. B.&nbsp;https:\/\/xxx.churchtools.de\/index.php?q=churchresource\/ajax Und per POST dann:&nbsp;func=getBookings (liefert alle Buchungen) oder z. B.&nbsp;func=getMasterData liefert alle notwendigen Stammdaten. Wichtig ist, dass der Aufruf \u00fcber POST-Befehl gesendet wird und die gew\u00fcnschte Funktion in dem Parameter &#8222;func=functioname&#8220; enthalten ist. Pro [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"doc_category":[370],"doc_tag":[268],"knowledge_base":[346],"class_list":["post-7254","docs","type-docs","status-publish","hentry","doc_category-api","doc_tag-inhalt-veraltet","knowledge_base-system-einstellungen"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"year_month":"2026-04","word_count":454,"total_views":"2729","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Hans-Helge B\u00fcrger","author_nicename":"hhbuerger","author_url":"https:\/\/churchtools.academy\/de\/author\/hhbuerger\/"},"doc_category_info":[{"term_name":"API","term_url":"https:\/\/churchtools.academy\/de\/help\/system-einstellungen\/api\/"}],"doc_tag_info":[{"term_name":"Inhalt veraltet","term_url":"https:\/\/churchtools.academy\/de\/docs-tag\/inhalt-veraltet\/"}],"knowledge_base_info":[{"term_name":"System-Einstellungen","term_url":"https:\/\/churchtools.academy\/de\/help\/system-einstellungen\/","term_slug":"system-einstellungen"}],"knowledge_base_slug":["system-einstellungen"],"_links":{"self":[{"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/docs\/7254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/comments?post=7254"}],"version-history":[{"count":10,"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/docs\/7254\/revisions"}],"predecessor-version":[{"id":44361,"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/docs\/7254\/revisions\/44361"}],"wp:attachment":[{"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/media?parent=7254"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/doc_category?post=7254"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/doc_tag?post=7254"},{"taxonomy":"knowledge_base","embeddable":true,"href":"https:\/\/churchtools.academy\/de\/wp-json\/wp\/v2\/knowledge_base?post=7254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}