Current Path : /var/www/u0635749/data/bitrix24.hobbyclick.ru/smstraffic-sms/ |
Current File : /var/www/u0635749/data/bitrix24.hobbyclick.ru/smstraffic-sms/messageServiceHandler.php |
<?php require_once __DIR__ . "/vendor/autoload.php"; require_once __DIR__ . "/config/mainConfig.php"; require_once __DIR__ . "/loggerInit.php"; use DevGuru\SmsTrafficApi\Client; use DevGuru\SmsTrafficApi\Sms\Sms; $request = file_get_contents('php://input'); $logger->debug('Incoming request01', ['data' => $request,"get"=>$_GET, "post"=>$_POST]); //$logger->debug('log request0', print_r(["get"=>$_GET, "post"=>$_POST],true)); $requestParsed = []; parse_str($request, $requestParsed); if (empty($requestParsed['message_to']) || empty($requestParsed['message_body'])) { die(); } $client = new Client($smsTrafficLogin, $smsTrafficPasswd); $phones = [$requestParsed['message_to']]; $message = $requestParsed['message_body']; $sms = new Sms($phones, $message); try { $result = $client->send($sms); $logger->debug('SMS sended', ['result' => $result]); } catch (\Exception $e) { $errorMsg = sprintf("%s (%s)", $e->getMessage(), $e->getCode()); $logger->error($errorMsg); }