定制 jc21/slack-notifications 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jc21/slack-notifications

最新稳定版本:1.3

Composer 安装命令:

composer require jc21/slack-notifications

包简介

A PHP interface for sending Notifications to your Slack team

README 文档

README

  • Send to any Channel or User
  • Full webhook options set supported
  • Attachments for nice field data display

Installing via Composer

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version:

composer.phar require jc21/slack-notifications

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Using

Class documentation

See the tests folder for some examples, but basically here's how to use it:

use jc21\SlackNotification;
use jc21\SlackAttachment;

$webhookUrl = 'your incoming webhook url';
$iconURl    = '';

// Create Attachment first
$attachment = new SlackAttachment();
$attachment->setFallback('Someone has tested the slack-notifications code successfully');
$attachment->setPretext('<https://github.com/jc21/slack-notifications|slack-notifications> was tested');
$attachment->setColor('#00ce3a');
$attachment->setAuthorName('Jamie Curnow');
$attachment->setAuthorLink('http://jc21.com');
$attachment->setAuthorIcon('https://avatars2.githubusercontent.com/u/1518257?v=3&s=460');

// Fields of the Attachment
$attachment->addField('Description', 'slack-notifications is a PHP package to help you out', false);
$attachment->addField('Type',        'Test',                                                 true);
$attachment->addField('Result',      'Success',                                              true);

// The notification, which uses the Attachment
$notification = new SlackNotification($webhookUrl);
$notification->setChannel('#general');  // Use @ for a username. ie: @jc21
$notification->setUsername('slack-notifications');
$notification->setIconUrl($iconUrl);
$notification->addAttachment($attachment);

try {
    $notification->send();
} catch (\Exception $e) {
    print 'Error: ' . $e->getMessage() . PHP_EOL;
    exit(1);
}

统计信息

  • 总下载量: 2.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD
  • 更新时间: 2015-06-29