2017 © Pedro Peláez
 

library slack-api

Wrapper for Slack.com WEB API.

image

vluzrmos/slack-api

Wrapper for Slack.com WEB API.

  • Saturday, October 22, 2016
  • by vluzrmos
  • Repository
  • 6 Watchers
  • 65 Stars
  • 58,941 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 30 Forks
  • 5 Open issues
  • 24 Versions
  • 19 % Grown

The README.md

Laravel e Lumen - Slack API

Join the chat at https://gitter.im/vluzrmos/laravel-slack-api, (*1)

This package provides a simple way to use Slack API., (*2)

Latest Stable Version Total Downloads Latest Unstable Version License, (*3)

Instalation

composer require vluzrmos/slack-api, (*4)

Instalation on Laravel

Add to config/app.php:, (*5)

This package uses auto-discovery laravel's feature, the service provider and all the facades will be automatic discovered., (*6)

Service Provider: \Vluzrmos\SlackApi\SlackApiServiceProvider::class, (*7)

Facades:, (*8)

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

Instalation on Lumen

Add that line on bootstrap/app.php:, (*9)

register('App\Providers\AppServiceProvider'); (by default that comes commented)
$app->register('Vluzrmos\SlackApi\SlackApiServiceProvider');

?>

If you want to use facades, add this lines on bootstrap/app.php, (*10)


Otherwise, just use the singleton shortcuts:, (*11)


Slack OAuth Token

To get your slack token, you must create an app on Slack Apps and then give the permissions that you need at your app page on side menu "Features" -> "OAuth & Permissions", and then go to "Scopes" section, the token can be a Bot Token or User Token as you need., (*12)

Then re/install the app to your workspace., (*13)

Note: If you edit any permission you must reinstall the app to your workspace., (*14)

Configuration

Configure your slack team token in config/services.php, (*15)

 [
        'token' => 'your token here'
    ]
]

?>

By default all api methods will return objects, to change it to associative array first publish slack-api config, and then set response_to_assoc_array to true, (*16)

php artisan vendor:publish --provider="Vluzrmos\SlackApi\SlackApiServiceProvider"

Usage

 '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

slackUser = $slackUser;
    }

    public function controllerMethod(){
        $usersList = $this->slackUser->lists();
    }
}

?>

All Injectable Contracts:

Generic API

Vluzrmos\SlackApi\Contracts\SlackApi, (*17)

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., (*18)

And is also possible load a SlackMethod contract:, (*19)

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

Vluzrmos\SlackApi\Contracts\SlackChannel, (*20)

Allows you to operate channels: invite, archive, rename, join, kick, setPurpose ..., (*21)

Chat API

Vluzrmos\SlackApi\Contracts\SlackChat, (*22)

Allows you to send, update and delete messages with methods: delete, message, update., (*23)

Files API

Vluzrmos\SlackApi\Contracts\SlackFile, (*24)

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

Groups API

Vluzrmos\SlackApi\Contracts\SlackGroup, (*26)

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

Instant Messages API (Direct Messages)

Vluzrmos\SlackApi\Contracts\SlackInstantMessage, (*28)

Allows you to manage direct messages to your team members., (*29)

Real Time Messages API

Vluzrmos\SlackApi\Contracts\SlackRealTimeMessage, (*30)

Allows you list all channels and user presence at the moment., (*31)

Search API

Vluzrmos\SlackApi\Contracts\SlackSearch, (*32)

Find messages or files., (*33)

Stars API

Vluzrmos\SlackApi\Contracts\SlackStar, (*34)

List all of starred itens., (*35)

Team API

Vluzrmos\SlackApi\Contracts\SlackTeam, (*36)

Get information about your team., (*37)

Users API

Vluzrmos\SlackApi\Contracts\SlackUser, (*38)

Get information about an user on your team or just check your presence ou status., (*39)

Users Admin API

Vluzrmos\SlackApi\Contracts\SlackUserAdmin, (*40)

Invite new members to your team., (*41)

OAuth API

Vluzrmos\SlackApi\Contracts\SlackOAuth, (*42)

Methods in oauth slack api namespace., (*43)

OAuthV2 API

Vluzrmos\SlackApi\Contracts\SlackOAuthV2, (*44)

Methods in oauth v2 slack api namespace., (*45)

License

DBAD License., (*46)

The Versions

22/10 2016

dev-master

9999999-dev

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

22/10 2016

v0.4.8

0.4.8.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

05/06 2016

v0.4.7

0.4.7.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

06/02 2016

v0.4.6

0.4.6.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

31/12 2015

v0.4.5

0.4.5.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

27/06 2015

v0.4.4

0.4.4.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

26/06 2015

v0.4.3

0.4.3.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

26/06 2015

v0.4.2

0.4.2.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

16/06 2015

v0.4.1

0.4.1.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

16/06 2015

v0.4.0

0.4.0.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

16/06 2015

v0.3.1

0.3.1.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

16/06 2015

v0.3.0

0.3.0.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

30/05 2015

v0.2.0

0.2.0.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

21/05 2015

v0.1.0

0.1.0.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

02/05 2015

v0.0.10

0.0.10.0

Wrapper for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel lumen slack

02/05 2015

v0.0.9

0.0.9.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

22/03 2015

v0.0.8

0.0.8.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

22/03 2015

v0.0.7

0.0.7.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

25/02 2015

v0.0.6

0.0.6.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

24/02 2015

v0.0.5

0.0.5.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

23/02 2015

v0.0.4

0.0.4.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

23/02 2015

v0.0.3

0.0.3.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

23/02 2015

v0.0.2

0.0.2.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack

23/02 2015

v0.0.1

0.0.1.0

Class for Slack.com WEB API.

  Sources   Download

dbad

The Requires

 

laravel api slack