/** * Get a xavi of an user by his id. * * @param int $id The user id. * * @return false|string */ public static function get($id) { if (!is_numeric($id)) { return false; } $http = new Http(); $response = $http->get('http://xat.com/json/xavi/get.php', ['u' => $id]); return $response->getBody(); }
/** * Get the ID by the room name or the name by the ID. * * @param string|int $name The name/id of the room. * * @return false|bool */ public static function getRoomInfo($name) { if (is_numeric($name)) { $url = 'http://xat.com/xat' . $name; } else { $url = 'http://xat.com/' . $name; } $http = new Http(); $response = $http->get($url); $roomId = Text::getBetween($response->getBody(), '<a href="http://xat.com/web_gear/chat/embed.php?id=', '&GroupName='); $roomName = Text::getBetween($response->getBody(), '&GroupName=', '"'); $title = Text::getBetween($response->getBody(), '<title>', '</title>'); $title = explode(' ', $title); if (!is_numeric($roomId) || $title[0] === 'xat') { return false; } else { Configure::write('Room.id', $roomId); Configure::write('Room.name', $roomName); $config = ['id' => $roomId, 'name' => $roomName]; return $config; } }