fab1en/rocket-chat-rest-client
最新稳定版本:1.0
Composer 安装命令:
composer require fab1en/rocket-chat-rest-client
包简介
Rocket Chat REST API client in PHP.
README 文档
README
Use this client if you need to connect to Rocket Chat with a software written in PHP, such as WordPress or Drupal.
How to use
This Rocket Chat client is installed via Composer. To install, simply add it to your composer.json file:
{ "require": { "fab1en/rocket-chat-rest-client": "dev-master" } } And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php $ php composer.phar update Then, import the autoload.php from your vendor folder.
After this, you have to define some constants to point to your Rocket Chat instance
define('REST_API_ROOT', '/api/v1/'); define('ROCKET_CHAT_INSTANCE', 'https://my-rocket-chat-instance.example.org');
Finally, instance the classes you need:
$api = new \RocketChat\Client(); echo $api->version(); echo "\n"; // login as the main admin user $admin = new \RocketChat\User('my-admin-name', 'my-admin-password'); if( $admin->login() ) { echo "admin user logged in\n"; }; $admin->info(); echo "I'm {$admin->nickname} ({$admin->id}) "; echo "\n";
Manage user
// create a new user $newuser = new \RocketChat\User('new_user_name', 'new_user_password', array( 'nickname' => 'New user nickname', 'email' => 'newuser@example.org', )); if( !$newuser->login(false) ) { // actually create the user if it does not exist yet $newuser->create(); } echo "user {$newuser->nickname} created ({$newuser->id})\n";
Post a message
// create a new channel $channel = new \RocketChat\Channel( 'my_new_channel', array($newuser, $admin) ); $channel->create(); // post a message $channel->postMessage('Hello world');
Credits
This REST client uses the excellent Httpful PHP library by Nate Good (github repo is here).
统计信息
- 总下载量: 80.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 50
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2026-01-04