gidkom/php-openfire-restapi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gidkom/php-openfire-restapi

Composer 安装命令:

composer require gidkom/php-openfire-restapi

包简介

Manage Openfire server using Rest Api

README 文档

README

Join the chat at https:#gitter.im/gidkom/php-openfire-restapi

Build Status

A simple PHP class designed to work with Openfire Rest Api plugin. It is used to remote manage the Openfire server.

LICENSE

php-openfire-restapi is licensed under MIT style license, see LICENCE for further information.

DEPENDENCIES

The REST API plugin need to be installed and configured on the Openfire server.

REQUIREMENTS

  • PHP 5.4+

INSTALLATION

With Composer

The easiest way to install is via composer. Create the following composer.json file and run the composer.phar install command to install it.

composer require gidkom/php-openfire-restapi:v1.1.0

OR

{
    "require": {
        "gidkom/php-openfire-restapi": "v1.1.0"
    }
}

EXAMPLE

SETUP

include "vendor/autoload.php";

SET PARAMETERS

# Create the Openfire Rest api object
$api = new Gidkom\OpenFireRestApi\OpenFireRestApi;

# Set the required config parameters
$api->secret = "MySecret";
$api->host = "jabber.myserver.com";
$api->port = "9090";  # default 9090

# Optional parameters (showing default values)

$api->useSSL = false;
$api->plugin = "/plugins/restapi/v1";  # plugin 

Response format

# Check result if command is succesful
if($result['status']) {
    # Display result
    print_r($result['data']);
} else {
    # Something went wrong
    echo 'Error: ';
    echo $result['data'];
}

User related examples

# Retrieve users
$options = ['search'=> 'John']; # optional
$result = $api->getUsers($options);

# Retrieve a user
$result = $api->getUser($username);

# Add a new user to OpenFire
# The $name and $email arguments are optional
$result = $api->addUser('Username', 'Password', 'Real Name', 'johndoe@domain.com');

# To also add the new user to one or more groups, call addToGroup afterwards:
$api->addToGroup('Username', 'Group 1');

#Delete a user from OpenFire
$result = $api->deleteUser($username);

# Update a user
# The $password, $name, $email arguments are optional.
# Note: Openfire's UserEntity does not accept a groups field — use addToGroup
# (or deleteFromGroup) to manage group membership for an existing user.
$result = $api->updateUser($username, $password, $name, $email);

# Add user to a group
$result = $api->addToGroup($username, $groupName);

# Delete user from a group
$result = $api->deleteFromGroup($username, $groupName);

# Disable/lockout a user
$result = $api->lockoutUser($username);

# Enable a user
$result = $api->unlockUser($username);

# Retrieve a user roster
$api->userRosters($username);

# Create a user roster entry
# The $nickname and $subscriptionType arguments are optional
$api->addToRoster($username, $jid, $nickname, $subscriptionType);

# Delete from roster
$api->deleteFromRoster($username, $jid);

# Update user roster
$api->updateRoster($username, $jid, $nickname, $subscriptionType);

# Push a roster event to a user's connected resources
$api->pushRosterEvent($username);

Chat room related Endpoints

# Get all chat rooms
$api->getAllChatRooms();

# Retrieve a chat room
$api->getChatRoom($name);

# Create a chat room
# $params  = ['naturalName'=>'myroom', 'roomName'=>'myroom', 'description'=>'my chat room']; 
$api->createChatRoom($params);

# Delete a chat room
$api->deleteChatRoom($roomName);

# Update a chat room
# $params  = ['naturalName'=>'myroom', 'roomName'=>'myroom', 'description'=>'my fav chat room'];  
$api->createChatRoom($roomName =>$params);

# Add user with role to chat room
$api->addUserRoleToChatRoom($roomName, $name, $role);

System related Endpoints

# Retrieve all system properties
$api->getSystemProperties();

# Retrieve a system property
$api->getSystemProperty('plugin.restapi.httpAuth');

# Create a system property
$api->createSystemProperty(['key'=>'test', 'value'=>'testname']);

# Update a system property
$api->updateSystemProperty(['key'=>'test', 'value'=>'testname']);

# Delete a system property
$api->deleteSystemProperty('test');

# Retrieve concurrent sessions
$api->getConcurrentSessons();

Group related Endpoints

# Get all groups
$api->getGroups();

# Retrieve group 
$api->getGroup($groupName);

# Create a group
$api->createGroup($groupName, $description);

# Update a group description
$api->updateGroup($groupName, $description);

# Delete a group
$api->deleteGroup($groupName);

Session related Endpoints

# Retrieve all users sessions
$api->getSessions();

# Retrieve all users sessions
$api->getUserSessions($username);

# Close all user sessions
$api->closeUserSessions($username);

Message related Endpoints

# Send a broadcast message to all online users
$api->broadcastMessage('hello');

# Clear archived message history between two users
# Requires Openfire Monitoring Service plugin to be installed
$api->clearMessages($username, $targetUsername);

CONTACT

gidkom/php-openfire-restapi 适用场景与选型建议

gidkom/php-openfire-restapi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 160.96k 次下载、GitHub Stars 达 57, 最近一次更新时间为 2015 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「chat」 「xmpp」 「openfire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 gidkom/php-openfire-restapi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gidkom/php-openfire-restapi 我们能提供哪些服务?
定制开发 / 二次开发

基于 gidkom/php-openfire-restapi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 160.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 58
  • 点击次数: 41
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 57
  • Watchers: 9
  • Forks: 39
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-17