mirror of
https://github.com/openvk/openvk
synced 2025-02-02 21:15:42 +03:00
Alexander Minkin
6ec54a379d
* feat(lint): add php-cs-fixer for linting Removing previous CODE_STYLE as it was not enforced anyway and using PER-CS 2.0. This is not the reformatting commit. * style: format code according to PER-CS 2.0 with php-cs-fixer * ci(actions): add lint action Resolves #1132.
39 lines
1,001 B
PHP
39 lines
1,001 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace openvk\Web\Util;
|
|
|
|
class Sms
|
|
{
|
|
public static function send(string $to, string $message): bool
|
|
{
|
|
$conf = (object) OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"];
|
|
if (!$conf->enable) {
|
|
return false;
|
|
}
|
|
|
|
$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;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|