From 92c9320eae4f2cf7544031b9c35e74f9e9e365b8 Mon Sep 17 00:00:00 2001 From: Alma Armas Date: Thu, 7 Jan 2021 16:25:09 +0000 Subject: [PATCH] Change SMS provider Co-authored-by: Celestine <34442450+rem-pai@users.noreply.github.com> --- Web/Util/Sms.php | 29 +++++++++++++++++++++-------- openvk-example.yml | 5 ++--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Web/Util/Sms.php b/Web/Util/Sms.php index dffea406..1a2f35ba 100644 --- a/Web/Util/Sms.php +++ b/Web/Util/Sms.php @@ -1,18 +1,31 @@ enable) return false; + $conf = (object) OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"]; + if(!$conf->enable) + return false; - try { - $api = new ZApi($conf->key, $conf->secret, false); - $res = $api->sendSms($to, $message, $conf->callerId); - } catch(ZException $e) { + $args = http_build_query([ + "login" => $conf->client, + "psw" => $conf->secret, + "phones" => $to, + "mes" => $message, + "flash" => 1, + "translit" => 2, + "fmt" => 2, + ]); + + $response = file_get_contents("https://smsc.ru/sys/send.php?$args"); + if(!$response) + return false; + + $response = new \SimpleXMLElement($response); + if(isset($response->error_code)) { + trigger_error("Could not send SMS to $to: $response->error (Exception $response->error_code)", E_USER_WARNING); return false; } diff --git a/openvk-example.yml b/openvk-example.yml index aea69495..825b2802 100644 --- a/openvk-example.yml +++ b/openvk-example.yml @@ -45,10 +45,9 @@ openvk: fartscroll: false testLabel: false credentials: - zadarma: + smsc: enable: false - callerId: "" - key: "" + client: "" secret: "" eventDB: enable: false # Better enable this