Package Data | |
---|---|
Maintainer Username: | wgmv |
Maintainer Contact: | vluzrmos@gmail.com (Vagner do Carmo) |
Package Create Date: | 2017-09-08 |
Package Last Update: | 2019-11-02 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:11:07 |
Package Statistics | |
---|---|
Total Downloads: | 23,287 |
Monthly Downloads: | 262 |
Daily Downloads: | 23 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
This package provides a simple way to use the Slack API.
The package is a fork from https://github.com/Vluzrmos/laravel-slack-api The original package is not maintained and I made several changes that possibly make this version incompatible to the original.
composer require wgmv/laravel-slack-api
The package has autodiscovery enabled. (A laravel 5.5 feature)
[
'providers' => [
Wgmv\SlackApi\SlackApiServiceProvider::class,
]
]
This package uses slacks legacy tokens. Get you token here:
https://api.slack.com/custom-integrations/legacy-tokens
Configure your slack team token in config/services.php
[
//...,
'slack' => [
'token' => 'your token here'
]
]
I have not tested the lumen installation! Documentation from the original package:
Add the following line on bootstrap/app.php
:
// $app->register('App\Providers\AppServiceProvider'); (by default that comes commented)
$app->register('Wgmv\SlackApi\SlackApiServiceProvider');
If you want to use facades, add this lines on bootstrap/app.php
class_alias('Wgmv\SlackApi\Facades\SlackApi', 'SlackApi');
//... and others
Otherwise, just use the singleton shortcuts:
/** @var \Wgmv\SlackApi\Contracts\SlackApi $slackapi */
$slackapi = app('slack.api');
/** @var \Wgmv\SlackApi\Contracts\SlackChannel $slackchannel */
$slackchannel = app('slack.channel');
etc
//Lists all users on your team
SlackUser::lists();
//Lists all channels on your team
SlackChannel::lists();
//List all groups
SlackGroup::lists();
//Invite a new member to your team
SlackUserAdmin::invite("example@example.com", [
'first_name' => 'John',
'last_name' => 'Doe'
]);
// or just use the helper
//Autoload the api
slack()->post('chat.postMessage', [...]);
//Autoload a Slack Method
slack('Chat')->message([...]);
slack('Team')->info();
Wgmv\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.
Wgmv\SlackApi\Contracts\SlackChannel
Allows you to operate channels:
invite
, archive
, rename
, join
, kick
, setPurpose
...
Wgmv\SlackApi\Contracts\SlackChat
Allows you to send, update and delete messages with methods:
delete
, message
, update
.
Wgmv\SlackApi\Contracts\SlackFile
Allows you to send, get info, delete, or just list files:
info
, lists
, upload
, delete
.
Wgmv\SlackApi\Contracts\SlackGroup
Same methods of the SlackChannel, but that operates with groups and have adicional methods:
open
, close
, createChild
Wgmv\SlackApi\Contracts\SlackInstantMessage
Allows you to manage direct messages to your team members.
Wgmv\SlackApi\Contracts\SlackRealTimeMessage
Allows you list all channels and user presence at the moment.
Wgmv\SlackApi\Contracts\SlackSearch
Find messages or files.
Wgmv\SlackApi\Contracts\SlackStar
List all of starred itens.
Wgmv\SlackApi\Contracts\SlackTeam
Get information about your team.
Wgmv\SlackApi\Contracts\SlackUser
Get information about an user on your team or just check your presence ou status.
Wgmv\SlackApi\Contracts\SlackUserAdmin
Invite new members to your team.