insidieux/slack-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

insidieux/slack-api

最新稳定版本:1.4.2

Composer 安装命令:

composer require insidieux/slack-api

包简介

Simple Slack API client wih predefined methods

README 文档

README

This project is very outdated and behind the current actual version of php, as well as the current version of the Slack API. We strongly DO NOT RECOMMEND you to use this library and we advise you to switch to one of the published packages from the official Slack documentation - https://api.slack.com/community#php

Build Status Code Climate Test Coverage Codacy Badge Codacy Badge

A simple PHP package for making request to Slack API, focused on ease-of-use and elegant syntax.

Requirements

Installation

You can install the package using the Composer package manager. You can install it by running this command in your project root:

composer require insidieux/slack-api

Usage

Create API client

$client = new \SlackApi\Client('your-token-here');

Make request

$client = new \SlackApi\Client('your-token-here');
$response = $client->request('module.method', ['argument' => 'value']);
$response->toArray();

Or you can use predefined modules and methods

$client = new \SlackApi\Client('your-token-here');
$response = $client->users()->getList();
$response->toArray()

Predefined modules:

Message and attachment objects

Create message object

$client = new \SlackApi\Client('your-token-here');
$message = new \SlackApi\Models\Message($client);

or

$client = new \SlackApi\Client('your-token-here');
$message = $client->makeMessage();

Create new attachment from array

$data = [
    'fallback' => 'Some fallback'
    'pretext'  => 'Some pretext',
    'text'     => 'good',
    'text'     => 'Some text'
]; 
$attachment1 = new \SlackApi\Models\Attachment($data);

Or use set methods

$attachment2 = new \SlackApi\Models\Attachment;
$attachment2->setText('Some text')
    ->setColor(\SlackApi\Models\Attachment::COLOR_GOOD)
    ->setFallback('Some fallback');

Add field to attachment

$field = new \SlackApi\Models\AttachmentField;
$field->setShort(false)
    ->setTitle('Field title')
    ->setValue('Field value');
$attachment->addField($field);

Attach object to message

$message->attach($attachment);

Send message

$response = $message->send();
$response->toArray()

Author

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-17