mirror of
https://github.com/openvk/openvk
synced 2024-11-14 11:09:12 +03:00
22 lines
568 B
PHP
22 lines
568 B
PHP
|
<?php declare(strict_types=1);
|
||
|
namespace openvk\Web\Util;
|
||
|
use Zadarma_API\{Api as ZApi, ApiException as ZException};
|
||
|
|
||
|
class Sms
|
||
|
{
|
||
|
function send(string $to, string $message): bool
|
||
|
{
|
||
|
$conf = (object) OPENVK_ROOT_CONF["openvk"]["credentials"]["zadarma"];
|
||
|
if(!$conf->enable) return false;
|
||
|
|
||
|
try {
|
||
|
$api = new ZApi($conf->key, $conf->secret, false);
|
||
|
$res = $api->sendSms($to, $message, $conf->callerId);
|
||
|
} catch(ZException $e) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|