tuemmlerkon / php-openfire-restapi
使用 Rest Api 管理Openfire服务器
1.2.2
2017-11-14 17:09 UTC
Requires
- php: >=5.4.0
- ext-curl: *
- doctrine/collections: ^1.4
- guzzlehttp/guzzle: ^5.3.1|^6.2.1
This package is not auto-updated.
Last update: 2024-09-20 01:46:58 UTC
README
一个简单的PHP类,用于与Openfire Rest Api插件协同工作。它用于远程管理Openfire服务器。
许可证
php-openfire-restapi遵循MIT风格许可证,有关更多信息,请参阅LICENCE。
需求
- PHP 5.4+
安装
使用Composer
最简单的安装方法是使用composer。创建以下composer.json
文件,并运行composer.phar
install命令进行安装。
{ "require": { "tuemmlerkon/php-openfire-restapi": "dev-master" } }
用法
include "vendor/autoload.php"; //define your settings in an array (these are the default values) define only that ones you want to change $settings = array( 'host' => 'localhost', 'port' => '9090', 'plugin' => '/plugins/restapi/v1', 'secret' => '', //required when 'useBasicAuth' is set to false 'useSSL' => true, 'useBasicAuth' => false, //if this option is set to true, you have also set 'basicUser' and 'basicPwd' 'basicUser' => '', 'basicPwd' => '', ); // Create the Openfire Rest api object $api = new TuemmlerKon\OpenFireRestApi\OpenFireRestApi($settings); //You are also able to use getter ans setter methods on these settings //e.g. $api->setEnableSSL(true);
为了更轻松地处理返回值,可以使用User
和Group
返回值的辅助类。
之后,您可以使用以下方法访问您的OpenFire安装
/** * Get all registered users * * @return ArrayCollection|false Returns all users within an ArrayCollection in error case false */ public function getUsers(); /** * Get information for a specified user * * @param $username * * @return false|User ArrayCollection when there are results and false if there was an error */ public function getUser($username); /** * Searches database for an specific user. Returns an ArrayCollection with one or more entries * on fault, method returns false * * @param $username * * @return bool|ArrayCollection */ public function searchUser($username); /** * Creates a new user from an User object * you can create one, for example, by calling createUser(new User('username', 'password', 'fullName', 'email')) * * @param User $user * * @return bool */ public function createUser(User $user); /** * Removes a user from OpenFire * * @param $username * * @return bool */ public function deleteUser($username); /** * Updates an user on OpenFire * * Important: It's not possible to change the password on this way * * @param User $user * * @return bool */ public function updateUser(User $user); /** * @param $username * * @return bool */ public function lockUserByUsername($username); /** * @param $username * * @return bool */ public function unlockUserByUsername($username); /** * locks/Disables an OpenFire user * * @param User $user * * @return bool */ public function lockUser(User $user); /** * unlocks/Enables an OpenFire user * * @param User $user * * @return bool */ public function unlockUser(User $user); /** * Retreives all associated groups for a user * * @param User $user * * @return bool|ArrayCollection */ public function getUserGroups(User $user); /** * Returns all groups in an ArrayCollection or an empty collection if nothing was found * Returns false on error * * @return bool|ArrayCollection */ public function getGroups(); /** * Returns a specific group by Group object * * @param Group $group * * @return bool|Group */ public function getGroup(Group $group); /** * Returns a specific group by groupname * * @param $groupname * * @return bool|Group */ public function getGroupByGroupname($groupname); /** * Create a group by Group object * * @param Group $group * * @return bool */ public function createGroup(Group $group); /** * Create a group by groupname * * @param string $groupname * @param string $description * * @return bool * */ public function createGroupByName($groupname, $description=""); /** * Delete a group by Group object * * @param Group $group * * @return bool */ public function deleteGroup(Group $group); /** * Delete a group by Group object * * @param $groupname * * @return bool */ public function deleteGroupByName($groupname); /** * @param Group $group * * @return bool */ public function updateGroup(Group $group); /** * Update a group by Group name * * Note: Description is required here * * @param string $groupname * @param string $description * * @return bool */ public function updateGroupByName($groupname, $description); /** * Adds Multiple groups to an specific user * @param User $user * @param ArrayCollection $groups * * @return bool */ public function addUserToGroups(User $user, ArrayCollection $groups); /** * Adds an user to an group by Group object * * @param User $user * @param Group $group * * @return bool */ public function addUserToGroup(User $user, Group $group); /** * Adds an user to an group by a given groupname * * @param User $user * @param string $groupname * * @return bool */ public function addUserToGroupByGroupName(User $user, $groupname); /** * Removes multiple groups from an specific user * @param User $user * @param ArrayCollection $groups * * @return bool */ public function removeUserFromGroups(User $user, ArrayCollection $groups); /** * Adds an user to an group by Group object * * @param User $user * @param Group $group * * @return bool */ public function removeUserFromGroup(User $user, Group $group); /** * Adds an user to an group by a given groupname * * @param User $user * @param string $groupname * * @return bool */ removeUserFromGroupByGroupName(User $user, $groupname);
开发
请随意添加新功能或通知我有关错误或问题。
联系方式
- 请通过konstantin@tuemmler.org给我发邮件