wrapi/slack

Slack Web API 的包装器

v1.0.3 2021-05-08 03:43 UTC

This package is auto-updated.

Last update: 2024-09-08 10:32:57 UTC


README

最简单 的客户端接口,用于访问 Slack Web API

Latest Stable Version License

安装

$ composer require "wrapi/slack:*"

使用方法

使用 API 令牌创建 Slack 客户端以连接到 Slack Web API。

$slack = new wrapi\slack\slack(SLACK_API_TOKEN);

// Now you are ready to make API calls to Slack.

为调用提供 API 参数。

API 调用遵循以下语法

$slack->apigroup->action($queryString);

  • queryString - (如需) API 方法参数作为键值对。

发布消息

$slack->chat->postMessage(array(
    "channel" => "#general",
    "text" => "Hello World!"
  )
)

示例

列出团队的定制表情符号。

$emojis = $slack->emoji->list();

列出 Slack 团队中的所有频道。

$channels = $slack->channels->list(array("exclude_archived" => 1));

获取关于私有组的详细信息。

$myGroup = $slack->groups->info(array("channel" => "G1234567890"));

对项目添加反应。

$slack->reactions->add(array(
    "name" => "thumbsup",
    "file" => "F1234567890",
    "file_comment" => "Fc1234567890",
    "channel" => "G1234567890",
    "timestamp" => "1234567890.123456"
  )
);

获取用户信息。

$user = $slack->users->info(array("user" => "U1234567890"));

将聊天消息发布到 Slack。

$response = $slack->chat->postMessage(array(
    "channel" => "#general",
    "text" => "Hello <@u12345678|world>!",
    "username" => "Wrapi Bot",
    "as_user" => false,
    "parse" => "full",
    "link_names" => 1,
    "unfurl_links" => true,
    "unfurl_media" => false
  )
)

API 函数

api

apps.permissions

apps.permissions.resources

apps.permissions.scopes

apps.permissions.users

apps

auth

bots

channels

chat

conversations

dialog

dnd

emoji

files.comments

files

groups

im

migration

mpim

oauth

pins

reactions

reminders

rtm

search

stars

team

team.profile

usergroups

usergroups.users

users

users.profile

License

MIT