Joywork/cron/createChatUser.php

45 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?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);
}
}