45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
|
|
<?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);
|
|||
|
|
}
|
|||
|
|
}
|