2017 © Pedro Peláez
 

library yii2-rocket-chat-rest-client

Yii2 Rocket Chat REST API client in PHP.

image

baha2odeh/yii2-rocket-chat-rest-client

Yii2 Rocket Chat REST API client in PHP.

  • Sunday, July 1, 2018
  • by Baha2Odeh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Rocket Chat REST API client in PHP

Use this client if you need to connect to Rocket Chat with a software written in PHP, such as WordPress or Drupal., (*1)

How to use

This Rocket Chat client is installed via Composer. To install, simply add it to your composer.json file:, (*2)

{
    "require": {
        "baha2odeh/yii2-rocket-chat-rest-client": "dev-master"
    }
}

And run composer to update your dependencies:, (*3)

$ php composer.phar update

After this, you have to register chat instance into components
common/config/main-local.php, (*4)

 'components' => [
    .....
    'chat' => [
            'class' => '\Baha2Odeh\RocketChat\Rocket',
            'rocket_chat_instance' => 'http://rocket-chat-server:3000',
            'rest_api_root' => '/api/v1/'
        ],

 ]

Finally, instance the classes you need:, (*5)

$user = \Yii::$app->chat->user();

        $info = [
            'name'=>'name',
            'username'=>'username',
            'email'=>'username@email.com',
            'pass'=>'123123123'
        ];

        if(($userInfo = $user->login($info['username'],$info['pass'],true))){
            print_r($userInfo);
        }else if($user->register($info) &&  ($userInfo = $user->login($info['username'],$info['pass'],true))){
            print_r($userInfo);
        }else{
            die($user->error);
        }




        $group = $user->group('group-name',[$userInfo->userId]);

        $group->create();

        $group->postMessage('Hello world');



Post a message

// create a new channel
$channel = $user->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)., (*6)

The Versions

01/07 2018

dev-master

9999999-dev

Yii2 Rocket Chat REST API client in PHP.

  Sources   Download

The Requires

 

20/06 2018

1.1

1.1.0.0

Yii2 Rocket Chat REST API client in PHP.

  Sources   Download

The Requires