From 457a6334698aeb581c011ca65ce2fb7fb2d0c604 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Fri, 19 Jul 2019 17:58:03 +0200 Subject: [PATCH] Supporto versione in OSMServices --- src/API/Services.php | 1 + src/Validate.php | 58 ++++++++++++-------------------------------- update/2_4_11.sql | 6 +++++ 3 files changed, 23 insertions(+), 42 deletions(-) diff --git a/src/API/Services.php b/src/API/Services.php index 726f4ea3a..6a162cbd0 100644 --- a/src/API/Services.php +++ b/src/API/Services.php @@ -24,6 +24,7 @@ class Services $json = array_merge($data, [ 'token' => setting('OSMCloud Services API Token'), + 'version' => setting('OSMCloud Services API Version'), 'resource' => $resource, ]); diff --git a/src/Validate.php b/src/Validate.php index 8bb6163d6..392a83bbb 100644 --- a/src/Validate.php +++ b/src/Validate.php @@ -1,5 +1,6 @@ warning(tr('Estensione cURL non installata')); - - return true; - } - - $qs = '&email='.urlencode($email); - $qs .= "&smtp=$smtp"; - $qs .= '&format=1'; - $qs .= '&resource=check_email'; - - $url = "https://services.osmcloud.it/api/?token=$access_key".$qs; - - $curl_options = [ - CURLOPT_URL => $url, - CURLOPT_HEADER => 0, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_TIMEOUT => 0, - CURLOPT_SSL_VERIFYPEER => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_ENCODING => 'gzip,deflate', - ]; - - $ch = curl_init(); - curl_setopt_array($ch, $curl_options); - $output = curl_exec($ch); - curl_close($ch); - - $data = json_decode($output, false); + if (Services::isEnabled()) { + $response = Services::request('get', 'check_email', [ + 'email' => $email, + 'smtp' => $smtp, + 'format' => 1, + ]); + $data = Services::responseBody($response); /*se la riposta è null verificando il formato, il record mx o il server smtp imposto la relativa proprietà dell'oggetto a 0*/ - if ($data->format_valid == null) { - $data->format_valid = 0; + if ($data['format_valid'] == null) { + $data['format_valid'] = 0; } - if ($data->mx_found == null && $smtp) { - $data->mx_found = 0; + if ($data['mx_found'] == null && $smtp) { + $data['mx_found'] = 0; } - if ($data->smtp_check == null && $smtp) { - $data->smtp_check = 0; + if ($data['smtp_check'] == null && $smtp) { + $data['smtp_check'] = 0; } - $data->smtp = $smtp; + $data['smtp'] = $smtp; - $data->json_last_error = json_last_error(); - $data->json_last_error_msg = json_last_error_msg(); - - return empty($data->format_valid) ? false : $data; + return empty($data['format_valid']) ? false : $data; } return true; diff --git a/update/2_4_11.sql b/update/2_4_11.sql index 9b29694f5..a825ea116 100644 --- a/update/2_4_11.sql +++ b/update/2_4_11.sql @@ -111,3 +111,9 @@ INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `e (NULL, 'v1', 'update', 'sessione_intervento', 'Modules\\Interventi\\API\\v1\\Sessioni', '1'), (NULL, 'v1', 'retrieve', 'articoli_intervento', 'Modules\\Interventi\\API\\v1\\Articoli', '1'), (NULL, 'v1', 'create', 'articolo_intervento', 'Modules\\Interventi\\API\\v1\\Articoli', '1'); + +-- Supporto alla personalizzazione dell'API remota OSMCloud +INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES +(NULL, 'OSMCloud Services API Version', 'v2', 'string', 0, 'Fatturazione Elettronica', 11); +DELETE FROM `zz_settings` WHERE `nome` = 'apilayer API key for Email'; +DELETE FROM `zz_settings` WHERE `nome` = 'apilayer API key for VAT number';