snapshotpl/zf-snap-hip-chat

此包最新版本(1.1)没有可用的许可证信息。

适用于 Zend Framework 2 的 HipChat 模块(API 和记录器)

1.1 2014-03-02 22:30 UTC

This package is auto-updated.

Last update: 2024-08-29 04:03:22 UTC


README

Zend Framework 2 的 HipChat 模块

此模块有助于使用 HipChat API 并将消息记录到您的房间!

最简单的使用方法

将认证令牌(您可以在 此处创建 - 请记住设置类型为 admin)添加到您的配置中

return array(
  'zf_snap_hip_chat' => array(
    'api' => array(
      'auth_token' => 'yourauthtoken',
    ),
  ),
);

然后从服务管理器获取 HipChat API 对象

$hipChat = $this->getServiceLocator()->get('hipchat');

就这样!模块使用 官方 HipChat PHP 库

如何安装?

通过 composer.json

{
  "require": {
    "snapshotpl/zf-snap-hip-chat": "1.*"
  }
}

并将模块 ZfSnapHipChat 添加到 application.config.php

将 HipChat 作为记录器使用

要将 HipChat 作为记录器使用,您需要在配置中设置房间 ID(ID)或名称(名称)

return array(
  'zf_snap_hip_chat' => array(
    'logger' => array(
      'room_id' => array(100001, 'log room'),
    ),
  ),
);

现在您可以通过服务管理器访问记录器

$logger = new Zend\Log\Logger();
$hipChat = $this->getServiceLocator()->get('hipchat_log_writer');
$logger->addWriter($hipChat);
$logger->debug('HipChat debug message!');

...或记录器

$logger = $this->getServiceLocator()->get('hipchat_logger');
$logger->debug('HipChat debug message!');

选项

您可以使用配置自定义记录器

return array(
  'zf_snap_hip_chat' => array(
    'api' => array(
      'auth_token' => null, // Required auth token
      'api_target' => HipChat::DEFAULT_TARGET, // Url address to HipChat API
      'api_version' => HipChat::VERSION_1, // Api version
    ),
    'logger' => array(
      'room_id' => null, // string, int or array with IDs, required for logger
      'from' => 'ZfSnapHipChat', // Author name for log messages in your rooms
      'notify' => false, // Enables sounds notify in HipChat
      'format' => HipChat::FORMAT_HTML, // Message format
    ),
  ),
);

控制台使用

您可以从应用程序控制台操作 HipChat API。要在控制台中获取命令列表,请写入命令

php public/index.php
HipChat API
  index.php hipchat message send <message> [--room=] [--from=] [--notify] [--color=(yellow|red|gray|green|purple|random)] [--format=(html|text)]    Sends message
  index.php hipchat room list    Lists rooms
  index.php hipchat room history <room> [--date=]    Room's history                           
  index.php hipchat room set topic <room> <topic> [--from=]    Sets room topic