gnello/php-openfire-restapi
Composer 安装命令:
composer require gnello/php-openfire-restapi
包简介
Client for the REST API plugin of the OpenFire Server
README 文档
README
A PHP client for the Openfire REST API Plugin which provides you the ability to manage an Openfire instance by sending a REST/HTTP request to the server.
Please read the documentation for further information on using this application.
This client completely supports the >= 1.3.9 version of the REST API Plugin.
Dependencies
The REST API plugin need to be installed and configured on your Openfire server.
Installation
Composer
The best way to install php-openfire-restapi is to use Composer, run the following command:
composer require gnello/php-openfire-restapi
Read more about how to install and use Composer here.
Usage
Instance and authentication
There are two ways of authentication:
- Basic HTTP Authentication
use Gnello\OpenFireRestAPI\Client; $client = new Client([ 'client' => [ 'username' => 'ironman', 'password' => 'romanoff', ] ]);
- Shared secret key
use Gnello\OpenFireRestAPI\Client; $client = new Client([ 'client' => [ 'secretKey' => 'hulkstink', ] ]);
Make sure to enable one of these authentication methods on your Openfire server.
Configuration
You can configure the Client with the following options:
use Gnello\OpenFireRestAPI\Client; $client = new Client([ 'client' => [ 'secretKey' => 'hulkstink', 'scheme' => 'https', 'basePath' => '/plugins/restapi/v1/', 'host' => 'localhost', 'port' => '9090', ], 'guzzle' => [ //put here any options for Guzzle ] ]);
The only options required are those relating to the chosen authentication method.
Check the response
This Client follows the PSR-7 document, therefore any response is a ResponseInterface type:
if ($response->getStatusCode() == 200) { echo "Oh, great."; var_dump(json_decode($response->getBody())); } else { echo "HTTP ERROR " . $response->getStatusCode(); }
Users endpoint
//Create a new user $response = $client->getUserModel()->createUser([ "username" => "admin", "name" => "Administrator", "email" => "admin@example.com", "password" => "p4ssword", "properties" => [ [ "key" => "console.order", "value" => "session-summary=0" ] ] ]); //Delete a user $response = $client->getUserModel()->deleteUser('ironman'); //Ban a user $response = $client->getUserModel()->lockoutUser('ironman'); //Unban a user $response = $client->getUserModel()->unlockUser('ironman'); //Please read the UserModel class for a complete list of available methods.
Chat Rooms endpoint
//Create a chat room $response = $client->getChatRoomModel()->createChatRoom([ "roomName" => "global-1", "naturalName" => "global-1_test_hello", "description" => "Global chat room", "subject" => "Global chat room subject", "creationDate" => "2012-10-18T16:55:12.803+02:00", "modificationDate" => "2014-07-10T09:49:12.411+02:00", "maxUsers" => "0", "persistent" => "true", "publicRoom" => "true", "registrationEnabled" => "false", "canAnyoneDiscoverJID" => "true", "canOccupantsChangeSubject" => "false", "canOccupantsInvite" => "false", "canChangeNickname" => "false", "logEnabled" => "true", "loginRestrictedToNickname" => "true", "membersOnly" => "false", "moderated" => "false", "broadcastPresenceRoles" => [ "moderator", "participant", "visitor" ], "owners" => [ "owner@localhost" ], "admins" => [ "admin@localhost" ], "members" => [ "member@localhost" ], "outcasts" => [ "outcast@localhost" ] ]); //Retrieve a chat room $response = $client->getChatRoomModel()->retrieveChatRoom('theavengers') //Add a user with role to a chat room use \Gnello\OpenFireRestAPI\Models\ChatRoomModel; $response = $client->getChatRoomModel()->addUserWithRoleToChatRoom('theavengers', 'ironman', ChatRoomModel::ROLE_MEMBER); //Delete a chat room $response = $client->getChatRoomModel()->deleteChatRoom('theavengers'); //Please read the ChatRoomModel class for a complete list of available methods.
Groups endpoint
//Create a group $response = $client->getGroupModel()->createGroup([ "name" => "theavengers", "description" => "team of superheroes appearing in American comic books published by Marvel Comics", ]); //Retrieve a group $response = $client->getGroupModel()->retrieveGroup('theavengers') //Delete a group $response = $client->getGroupModel()->deleteGroup('theavengers'); //Please read the GroupModel class for a complete list of available methods.
Endpoints supported
All the endpoints are supported:
Contact
- gnello luca@gnello.com
gnello/php-openfire-restapi 适用场景与选型建议
gnello/php-openfire-restapi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.19k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2016 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「chat」 「openfire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gnello/php-openfire-restapi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gnello/php-openfire-restapi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gnello/php-openfire-restapi 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Manage Openfire server using Rest Api
This simple PHP class allows you to easily generate Smartsupp.com JS chat code.
The Yii2 extension module to chat registered users.
Chat Package for Laravel
ZF2 PHP WebSocket Server Factory v2.1 (Extended)
统计信息
- 总下载量: 14.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2016-06-25