geekdpt/slamp 问题修复 & 功能扩展

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

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

geekdpt/slamp

Composer 安装命令:

composer require geekdpt/slamp

包简介

Asynchronous Slack client for PHP, with Web & RTM APIs support

README 文档

README

Slamp logo

slamp

An asynchronous Slack RTM & Web APIs client for PHP 7, powered by the Amp asynchronous framework, providing a typed experience and full-featured interfaces.

Forget those cURL wrappers and go async!

SensioLabsInsight Packagist (Composer) MIT License

  1. Installation
  2. Usage we'll learn how to do those node-ish things
  3. Slamp APIs
  4. Error handling because sh** always happens

Installation

Usage

Web API

Simple Message Composing

Inspired by maknz/slack, this API is based on top of the Web API and intends to provide a simple interface for sending messages to channels, groups or IM channels. You have to create a Web API client to begin, then call compose() to create a new message instance.

A basic usage example could be:

$client = Slamp\webClient(TOKEN);
yield $client->compose()->sendAsync('Hello there!');

You can also set the target channel and/or the bot name :

yield $client->compose()->from('Hello Bot')->to('#general')->sendAsync('Hey, wassup #general?');

The to("...") argument supports different notations:

  • #channel, C024BE91L for a public channel
  • private-group, G012AC86C for a private group
  • @username to post an IM message to the @slackbot inbox of the receiver (you will not appear as "slackbot")
  • D023BB3L2 to post as the bot itself (and not slackbot like before) (you have to create such channel before)

You can even edit messages or delete them after they are sent:

$message = yield $client->compose()->to('@guy')->sendAsync('I hate you');

# What I have done.. ?!
yield $message->updateAsync('I love u');

# I should calm down...
yield $message->deleteAsync();

Here is a more complete list of the possible calls:

$msg = Slamp\webClient(TOKEN)->compose()
    ->from('Sender name')
    ->withIcon(':robot:') # emoji code, or custom image with an URL
    ->to('#channel')
    ->withParsing('full') # defaults to "none", see api.slack.com/docs/message-formatting
    ->linkingNames(true) # defaults to false, sets whether token like #general or @username are parsed and transformed into links
    ->sendAsync('the message text');
    
Amp\wait($msg);

Note: attachments are not yet supported.

Warning: Please do not rely on the type behind these methods. Just use the methods. Don't manipulate the MessageComposer direclty, as the way it is created may change radically in a future version.

RTM API

Error handling

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固