ontanj/slack-payload

从 Slack 消息体中提取信息

v1.0.0 2018-02-01 14:04 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:02:28 UTC


README

当使用 Slack API 中的交互式消息时,结果以 json 编码数组的形式通过 $_POST["payload"] 返回。此应用程序帮助从该消息体中提取信息。

安装

composer require ontanj/slack-payload

使用方法

Payload 类位于命名空间 SlackPayload 中。

要实例化 Payload 类,将 $_POST["payload"] 传递给构造函数。现在您可以通过对象的功能来接收信息。

可用功能

/**
 * Gets callback id for the used attachment
 * @return string callback id
 */
public function callback_id() : string

/**
 * Gets id for the channel the message came from
 * @return string channel id
 */
public function channel_id() : string

/**
 * Gets name of the channel the message came from
 * @return string channel name
 */
public function channel_name() : string

/**
 * Gets the choice made, either selected list item or pressed button.
 * @return string value of choice
 */
public function choice() : string

/**
 * Gets the name of the menu where the list item was chosen.
 * If choice wasn't made from a list, the button value is returned.
 * @return string menu name
 */
public function menu_name() : string

/**
 * Gets the URL to return a response to
 * @return string URL
 */
public function response_url() : string

/**
 * Gets the id of the slack team where the message was sent from.
 * @return string team id
 */
public function team_id() : string

/**
 * Gets the name of the slack team where the message was sent from.
 * @return string team name
 */
public function team_name() : string

/**
 * Gets the id of the user performing the action
 * @return string user id
 */
public function user_id() : string

/**
 * Gets the name of the user performing the action
 * @return string user name
 */
public function user_name() : string

未来

目标是包含更多功能。欢迎贡献力量。