9e1bd04af49345890afa9a2cb2557cc0c2e4a094
Bernd Wurst Grundlegende API-Routine

Bernd Wurst authored 6 years ago

1) <?php
2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
5) Written 2008-2018 by schokokeks.org Hosting, namely
6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
16) 
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

17) require_once('contacts.php');
Bernd Wurst Grundlegende API-Routine

Bernd Wurst authored 6 years ago

18) require_once('inc/debug.php');
19) 
20) function api_request($method, $input_data) 
21) {
22)     $url = config('http.net-apiurl').'domain/v1/json/'.$method;
23)     $input_data['authToken'] = config('http.net-apikey');
24)     DEBUG('======= API REQUEST ==========');
25)     DEBUG($url);
26)     DEBUG($input_data);
27)     $curl = curl_init($url);
28)     $json = json_encode($input_data);
29)     curl_setopt($curl, CURLOPT_POST, 1);
30)     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
31)     curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
32)     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
33)     $result = curl_exec($curl);
34)     if ($result === FALSE) {
35)         system_failure("API-Anfrage kaputt");
36)     }
37)     DEBUG('==============================');
38)     DEBUG($result);
39)     $output_data = json_decode($result, true);
40)     DEBUG($output_data);
41)     return $output_data;
42) }