hannesvdvreken / hipchat
此包已被弃用且不再维护。未建议替代包。
Hipchat通知的notifier类
v0.1.0
2014-01-26 20:37 UTC
Requires
- php: >=5.3.0
- guzzle/http: 3.8.*
Requires (Dev)
- illuminate/support: 4.1.*
This package is auto-updated.
Last update: 2019-10-25 09:06:48 UTC
README
使用方法
从Hello World示例开始。
// Configuration. $rooms = [ [ 'room_id' => '1234', 'auth_token' => '****', ], ]; // Create the required Guzzle client. $client = new Guzzle\Http\Client; $hipchat = new Hipchat\Notifier($client, $rooms); // Send the notification. $hipchat->notify('Hello world!');
如果您想向不同的房间发送通知,请将它们添加到数组中。
// Configuration. $rooms = [ 'frontenders' => [ 'room_id' => '1234', 'auth_token' => '****', ], 'backenders' => [ 'room_id' => '5678', 'auth_token' => '****', ], ]; // Create the required Guzzle client. $client = new Guzzle\Http\Client; $hipchat = new Hipchat\Notifier($client, $rooms); // Send the notification. $hipchat->notifyIn('frontenders', 'Hello world!');
默认房间是数组中的第一个房间,或者您可以通过第三个构造参数指定要使用的默认房间。
额外配置。
构造函数接受一个带有额外选项的第三个参数。
$config = [ 'default' => 'frontenders', 'color' => 'gray', 'pretend' => true, 'notify' => true, ];
default
:使用->notify()
发送通知的默认房间。color
:从yellow
、red
、green
、purple
、gray
或random
中选择。pretend
:实际上不发送任何消息。notify
:让Hipchat发出声音。
颜色
根据消息类型,使用notify
和notifyIn
方法的第二个和第三个参数选择颜色。
// Example 1 $color = $error ? 'red' : 'green'; $hipchat->notify($message, $color); // Example 2 $hipchat->notifyIn('frontenders', $message, 'purple');
Laravel 4
此包附带Laravel 4服务提供程序。将以下行添加到app.php
中的providers数组。
'Hipchat\Support\ServiceProvider',
它还注册了 Facade 类 Hipchat\Support\Facades\Hipchat
的别名,因此您可以直接使用 Hipchat::notify($message)
和 Hipchat::notifyIn('frontenders', $message)
。
使用以下命令发布默认配置
php artisan config:publish hannesvdvreken/hipchat
所有可配置选项都可以在这里找到。
贡献
请随意提交拉取请求。请尽可能遵守PSR-2编码风格指南。