Joywork/cron/createChatUser.php
2026-05-22 21:21:54 +03:00

45 lines
1.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
set_time_limit(0);
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Работа с чатом</title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
$userId = 9877;
$user = new User;
$user->get($userId);
$userSettings = RocketChat::getUserChatSettings($userId);
if (!$userSettings || !$userSettings['chat_login']) {
//создаем пользователя
$result = RocketChat::createChatUser($user);
if ($result['success']) {
$userSettings = $result['user'];
} else {
var_dump($result);
}
}
if (!$userSettings['chat_token'] && $userSettings['chat_login']) {
//логиним для получения ИД пользователя в чате
$result = RocketChat::loginUser($userId);
if ($result['success']) {
$userSettings = $result['user'];
} else {
var_dump($result);
}
}