9d94ce02f4a85477242cba9df67764dc10cae67b
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) }
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

43) 
44) 
45) 
46) function contact_to_apicontact($c) 
47) {
48)     $ac = array();
49)     $ac['id'] = $c['nic_id'];
50)     $ac['handle'] = $c['nic_handle'];
51)     $ac['type'] = 'person';
52)     $ac['name'] = $c['name'];
53)     $ac['organization'] = $c['company'];
54)     $ac['street'] = explode("\n", $c['address'], 3);
55)     $ac['postalCode'] = $c['zip'];
56)     $ac['city'] = $c['city'];
57)     $ac['country'] = strtolower($c['country']);
58)     $ac['emailAddress'] = $c['email'];
59)     $ac['phoneNumber'] = $c['phone'];
60)     $ac['faxNumber'] = $c['fax'];
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

61)     if ($c['state'] == 'deleted') {
62)         $ac['hidden'] = true;
63)     }