openfire的api接口控制

首先確保你的openfire已安裝restapi

在openfire后臺(tái)管理->插件管理中下載并啟用restapi
部署以后默認(rèn)是沒(méi)有開(kāi)啟的,你需要到后臺(tái)開(kāi)啟并且設(shè)置驗(yàn)證碼(即為secret),為了確保安全你也許還要設(shè)置一個(gè)安全的ip

引入php-openfire-restapi的代碼

github上的托管地址:https://github.com/gidkom/php-openfire-restapi

使用composer方式引入類(lèi)

    composer require "gidkom/php-openfire-restapi:dev-master"

可以在Gidkom\OpenFireRestApi\OpenFireRestApi類(lèi)中配置默認(rèn)屬性

class OpenFireRestApi
{
    public $host        = 'xmpp.xxxxxx.net';
    public $port        = '9090';
    public $plugin    = '/plugins/restapi/v1';
    public $secret    = 'xxxxxxxx';
    public $useSSL    = false;
    protected $params   = array();
    public $client;

    /////////
}

或者實(shí)例化對(duì)象后,重新定義屬性

include "vendor/autoload.php";
$api = new Gidkom\OpenFireRestApi\OpenFireRestApi;

// 設(shè)置必須的配置項(xiàng)參數(shù)
$api->secret = "MySecret";
$api->host = "jabber.myserver.com";
$api->port = "9090";  // default 9090

// 可選的參數(shù) (沒(méi)有設(shè)置為默認(rèn)值)
$api->useSSL = false;
$api->plugin = "/plugins/restapi/v1";  // plugin 

// 創(chuàng)建一個(gè)新用戶(hù)
$result = $api->addUser('Username', 'Password', 'Real Name', 'Email', array('Group 1'));

//刪除一個(gè)用戶(hù)
$result = $api->deleteUser($username);


//禁用一個(gè)用戶(hù)
$result = $api->lockoutUser($username);


//啟用一個(gè)用戶(hù)
$result = $api->unlockUser($username);

/**
 * 更新用戶(hù)信息
 *
 * The $password, $name, $email, $groups arguments are optional
 * 
 */
$result = $api->updateUser($username, $password, $name, $email, $groups)

// 添加到名冊(cè)中
$api->addToRoster($username, $jid);

// 從名冊(cè)中刪除
$api->addToRoster($username, $jid);

// 更新名冊(cè)的用戶(hù)信息
$api->updateRoster($username, $jid, $nickname, $subscription);

// 獲取所有組
$api->getGroup();

// 獲取某組信息 
$api->getGroup($name);

// 創(chuàng)建一個(gè)組
$api->createGroup($group_name, $description);

// 更新某組的描述
$api->updateGroup($group_name, $description);

// 刪除某組
$api->deleteGroup($group_name);

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 134,993評(píng)論 19 139
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,560評(píng)論 25 708
  • 我一個(gè)人呆呆地坐在窗前,望著16層樓外的風(fēng)景,雖是滿(mǎn)眼的繁華,卻難填平內(nèi)心的落寞。最近不知怎的突然很不想一個(gè)人待著...
    路人小A閱讀 743評(píng)論 0 0
  • 緣起于一次臨睡前的聊天,內(nèi)人問(wèn)我一個(gè)問(wèn)題。 她說(shuō):“你做茶什么時(shí)候能發(fā)財(cái)呢?” 我想了想說(shuō):“假如做茶能發(fā)財(cái)?shù)脑挘?..
    曹胖閱讀 418評(píng)論 4 10
  • 星星之隊(duì)徐逸翔打卡《綠山墻的安妮》第七天。 今天把這本書(shū)看光了。我就來(lái)講一講我今天看到主要內(nèi)容吧!...
    多多_bc5b閱讀 228評(píng)論 0 0