承接 craftyx/slack-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

craftyx/slack-api

Composer 安装命令:

composer require craftyx/slack-api

包简介

Wrapper for Slack.com WEB API. Based on Vagner do Carmo one, but compatible with GuzzleHttp6

README 文档

README

This package provides a simple way to use Slack API. It's based on the excellent Vluzrmos package, but it's compatible with Guzzle6

Instalation

composer require craftyx/slack-api

Instalation on Laravel 5

Add to config/app.php:

<?php 

[
    'providers' => [
        Craftyx\SlackApi\SlackApiServiceProvider::class,
    ]
]

?>

The ::class notation is optional.

and add the Facades to your aliases, if you need it

<?php

[
    'aliases' => [
        'SlackApi'              => Craftyx\SlackApi\Facades\SlackApi::class,
        'SlackChannel'          => Craftyx\SlackApi\Facades\SlackChannel::class,
        'SlackChat'             => Craftyx\SlackApi\Facades\SlackChat::class,
        'SlackGroup'            => Craftyx\SlackApi\Facades\SlackGroup::class,
        'SlackFile'             => Craftyx\SlackApi\Facades\SlackFile::class,
        'SlackSearch'           => Craftyx\SlackApi\Facades\SlackSearch::class,
        'SlackInstantMessage'   => Craftyx\SlackApi\Facades\SlackInstantMessage::class,
        'SlackUser'             => Craftyx\SlackApi\Facades\SlackUser::class,
        'SlackStar'             => Craftyx\SlackApi\Facades\SlackStar::class,
        'SlackUserAdmin'        => Craftyx\SlackApi\Facades\SlackUserAdmin::class,
        'SlackRealTimeMessage'  => Craftyx\SlackApi\Facades\SlackRealTimeMessage::class,
        'SlackTeam'             => Craftyx\SlackApi\Facades\SlackTeam::class,
    ]
]

?>

The ::class notation is optional.

Configuration

configure your slack team token in config/services.php

<?php

[
    //...,
    'slack' => [
        'token' => 'your token here'
    ]
]

?>

Usage

<?php

//Lists all users on your team
SlackUser::lists(); //all()

//Lists all channels on your team
SlackChannel::lists(); //all()

//List all groups
SlackGroup::lists(); //all()

//Invite a new member to your team
SlackUserAdmin::invite("example@example.com", [
    'first_name' => 'John', 
    'last_name' => 'Doe'
]);

//Send a message to someone or channel or group
SlackChat::message('#general', 'Hello my friends!');

//Upload a file/snippet
SlackFile::upload([
    'filename' => 'sometext.txt', 
    'title' => 'text', 
    'content' => 'Nice contents',
    'channels' => 'C0440SZU6' //can be channel, users, or groups ID
]);

// Search for files or messages
SlackSearch::all('my message');

// Search for files
SlackSearch::files('my file');

// Search for messages
SlackSearch::messages('my message');

// or just use the helper

//Autoload the api
slack()->post('chat.postMessage', [...]);

//Autoload a Slack Method
slack('Chat')->message([...]);
slack('Team')->info();

?>

Using Dependency Injection

<?php 

namespace App\Http\Controllers;    
    
use Craftyx\SlackApi\Contracts\SlackUser;

class YourController extends Controller{
    /** @var  SlackUser */
    protected $slackUser;
    
    public function __construct(SlackUser as $slackUser){
        $this->slackUser = $slackUser;   
    }
    
    public function controllerMethod(){
        $usersList = $this->slackUser->lists();
    }
}

?>

All Injectable Contracts:

Generic API

Craftyx\SlackApi\Contracts\SlackApi

Allows you to do generic requests to the api with the following http verbs: get, post, put, patch, delete ... all allowed api methods you could see here: Slack Web API Methods.

And is also possible load a SlackMethod contract:

<?php 

/** @var SlackChannel $channel **/
$channel = $slack->load('Channel');
$channel->lists();

/** @var SlackChat $chat **/
$chat = $slack->load('Chat');
$chat->message('D98979F78', 'Hello my friend!');

/** @var SlackUserAdmin $chat **/
$admin = $slack('UserAdmin'); //Minimal syntax (invokable)
$admin->invite('jhon.doe@example.com'); 

?>

Channels API

Craftyx\SlackApi\Contracts\SlackChannel

Allows you to operate channels: invite, archive, rename, join, kick, setPurpose ...

Chat API

Craftyx\SlackApi\Contracts\SlackChat

Allows you to send, update and delete messages with methods: delete, message, update.

Files API

Craftyx\SlackApi\Contracts\SlackFile

Allows you to send, get info, delete, or just list files: info, lists, upload, delete.

Groups API

Craftyx\SlackApi\Contracts\SlackGroup

Same methods of the SlackChannel, but that operates with groups and have adicional methods: open, close, createChild

Instant Messages API (Direct Messages)

Craftyx\SlackApi\Contracts\SlackInstantMessage

Allows you to manage direct messages to your team members.

Real Time Messages API

Craftyx\SlackApi\Contracts\SlackRealTimeMessage

Allows you list all channels and user presence at the moment.

Search API

Craftyx\SlackApi\Contracts\SlackSearch

Find messages or files.

Stars API

Craftyx\SlackApi\Contracts\SlackStar

List all of starred itens.

Team API

Craftyx\SlackApi\Contracts\SlackTeam

Get information about your team.

Users API

Craftyx\SlackApi\Contracts\SlackUser

Get information about an user on your team or just check your presence ou status.

Users Admin API

Craftyx\SlackApi\Contracts\SlackUserAdmin

Invite new members to your team.

License

DBAD License.

craftyx/slack-api 适用场景与选型建议

craftyx/slack-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.35k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「slack」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 craftyx/slack-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 craftyx/slack-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 craftyx/slack-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 62
  • 开发语言: PHP

其他信息

  • 授权协议: DBAD
  • 更新时间: 2015-11-07