PHP code example of tuemmlerkon / php-openfire-restapi
1. Go to this page and download the library: Download tuemmlerkon/php-openfire-restapi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tuemmlerkon / php-openfire-restapi example snippets
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' => '', //ettings);
//You are also able to use getter ans setter methods on these settings
//e.g. $api->setEnableSSL(true);
/**
* 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