2017 © Pedro Peláez
 

yii2-extension yii2-beary-chat

yii2 bearyChat component

image

kriss/yii2-beary-chat

yii2 bearyChat component

  • Thursday, March 9, 2017
  • by kriss
  • Repository
  • 1 Watchers
  • 2 Stars
  • 97 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

yii2 bearyChat

yii2 bearyChat 组件,依赖BearyChat for PHP, (*1)

安装

推荐使用 composer., (*2)

php composer.phar require --prefer-dist kriss/yii2-beary-chat "*"

或添加下面代码到composer.json文件, (*3)

"kriss/yii2-beary-chat": "*"

然后使用, (*4)

php composer.phar update

使用方式

单独使用

1.进行配置, (*5)

basic 模版为 config/web.php, advanced 模版为对应入口的 config/main.php, (*6)

示例配置如下:, (*7)

'components' => [
    .....
    'bearyChat' => [
        'class' => 'kriss\bearyChat\Incoming',
        'clients' => [
            'default' => [
                'webhook' => 'https://hook.bearychat.com/=XXXX/incoming/XXXXXXXXXXXXXX',
                 'message_defaults' => [
                     'attachment_color' => '#f5f5f5',
                 ]
            ],
            // 'admin' => [
            //     'webhook' => '',
            // ],
        ]
    ],
    ...
]

2.进行使用, (*8)

最简单的使用方式:, (*9)

Yii::app->bearyChat->client()->sendMessage(json_encode(['text'=>'hello world']));

更多使用方式参看: BearyChat for PHP, (*10)

tips:Yii::app->bearyChat->client()获得的即是\ElfSundae\BearyChat\Client, (*11)

配合 yii2-thread 使用

发送一条 BearyChat 消息实际上是向 Incoming Webhook 发送同步 HTTP 请求,所以这在一定程度上会延长应用的响应时间。可以使用 yii2-thread (或任意多线程方式)来异步发送消息。, (*12)

使用 yii2-thread 只需要在对应位置使用发送消息的代码就可以,使用方式不变, (*13)

参考链接:yii2-thread, (*14)

The Versions

09/03 2017

dev-master

9999999-dev https://github.com/krissss/yii2-beary-chart

yii2 bearyChat component

  Sources   Download

MIT

The Requires

 

by Avatar kriss

yii2 robot bearychat incoming webhook

14/07 2016

1.0

1.0.0.0 https://github.com/krissss/yii2-beary-chart

yii2 bearyChat component

  Sources   Download

MIT

The Requires

 

by Avatar kriss

yii2 robot bearychat incoming webhook