Current Path : /var/www/u0635749/data/bitrix24.hobbyclick.ru/smstraffic-sms/commands/ |
Current File : /var/www/u0635749/data/bitrix24.hobbyclick.ru/smstraffic-sms/commands/deleteMessageService.php |
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../config/mainConfig.php"; require_once __DIR__ . "/../loggerInit.php"; if (!empty($argv[1])) { $senderId = $argv[1]; } else { print("Sender ID is required\n"); die(); } $b24Config = json_decode(file_get_contents(__DIR__ . "/../config/b24Config.json"), true); try { $obB24App = new \Bitrix24\Bitrix24(false, $logger); $obB24App->setApplicationId($b24Config["applicationId"]); $obB24App->setApplicationSecret($b24Config["applicationCode"]); $obB24App->setApplicationScope($b24Config["applicationScope"]); $obB24App->setDomain($b24Config["b24name"] . ".bitrix24.ru"); $obB24App->setMemberId($b24Config["memberId"]); $obB24App->setAccessToken($b24Config["accessToken"]); $obB24App->setRefreshToken($b24Config["refreshToken"]); $obB24App->setRedirectUri($b24Config["redirectUri"]); if ($obB24App->isAccessTokenExpire()) { $requestResult = $obB24App->getNewAccessToken(); $obB24App->setAccessToken($requestResult["access_token"]); $b24Config["accessToken"] = $requestResult["access_token"]; $b24Config["refreshToken"] = $requestResult["refresh_token"]; file_put_contents(__DIR__ . "/../config/b24Config.json", json_encode($b24Config)); } $messageServiceObj = new \Bitrix24\MessageService\MessageService($obB24App); $b24Response = $messageServiceObj->delete($senderId); print_r($b24Response); $logger->debug('B24 messageservice delete response', ['response' => $b24Response]); $logger->debug('log request2', print_r(['b24Config' => $b24Config,"get"=>$_GET, "post"=>$_POST],true)); } catch (\Bitrix24\Exceptions\Bitrix24TokenIsExpiredException $e) { $errorMsg = 'Истек срок действия access и refresh токенов'; $logger->error($errorMsg, ['b24Config' => $b24Config,"get"=>$_GET, "post"=>$_POST]); } catch (Exception $e) { $errorMsg = $e->getMessage(); $logger->error($errorMsg); }