dev-master
9999999-devWrapper for Slack.com WEB API. Based on Vagner do Carmo one, but compatible with GuzzleHttp6
dbad
The Requires
by Daniel Baron
by Julien Tant
laravel lumen slack
Wallogit.com
2017 © Pedro Peláez
Wrapper for Slack.com WEB API. Based on Vagner do Carmo one, but compatible with GuzzleHttp6
This package provides a simple way to use Slack API. It's based on the excellent Vluzrmos package, but it's compatible with Guzzle6, (*1)
composer require craftyx/slack-api, (*2)
Add to config/app.php:, (*3)
[
Craftyx\SlackApi\SlackApiServiceProvider::class,
]
]
?>
The ::class notation is optional., (*4)
and add the Facades to your aliases, if you need it, (*5)
[
'SlackApi' => Craftyx\SlackApi\Facades\SlackApi::class,
'SlackChannel' => Craftyx\SlackApi\Facades\SlackChannel::class,
'SlackChat' => Craftyx\SlackApi\Facades\SlackChat::class,
'SlackGroup' => Craftyx\SlackApi\Facades\SlackGroup::class,
'SlackFile' => Craftyx\SlackApi\Facades\SlackFile::class,
'SlackSearch' => Craftyx\SlackApi\Facades\SlackSearch::class,
'SlackInstantMessage' => Craftyx\SlackApi\Facades\SlackInstantMessage::class,
'SlackUser' => Craftyx\SlackApi\Facades\SlackUser::class,
'SlackStar' => Craftyx\SlackApi\Facades\SlackStar::class,
'SlackUserAdmin' => Craftyx\SlackApi\Facades\SlackUserAdmin::class,
'SlackRealTimeMessage' => Craftyx\SlackApi\Facades\SlackRealTimeMessage::class,
'SlackTeam' => Craftyx\SlackApi\Facades\SlackTeam::class,
]
]
?>
The ::class notation is optional., (*6)
configure your slack team token in config/services.php, (*7)
[
'token' => 'your token here'
]
]
?>
'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();
?>
slackUser = $slackUser;
}
public function controllerMethod(){
$usersList = $this->slackUser->lists();
}
}
?>
Craftyx\SlackApi\Contracts\SlackApi, (*8)
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., (*9)
And is also possible load a SlackMethod contract:, (*10)
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');
?>
Craftyx\SlackApi\Contracts\SlackChannel, (*11)
Allows you to operate channels:
invite, archive, rename, join, kick, setPurpose ..., (*12)
Craftyx\SlackApi\Contracts\SlackChat, (*13)
Allows you to send, update and delete messages with methods:
delete, message, update., (*14)
Craftyx\SlackApi\Contracts\SlackFile, (*15)
Allows you to send, get info, delete, or just list files:
info, lists, upload, delete., (*16)
Craftyx\SlackApi\Contracts\SlackGroup, (*17)
Same methods of the SlackChannel, but that operates with groups and have adicional methods:
open, close, createChild, (*18)
Craftyx\SlackApi\Contracts\SlackInstantMessage, (*19)
Allows you to manage direct messages to your team members., (*20)
Craftyx\SlackApi\Contracts\SlackRealTimeMessage, (*21)
Allows you list all channels and user presence at the moment., (*22)
Craftyx\SlackApi\Contracts\SlackSearch, (*23)
Find messages or files., (*24)
Craftyx\SlackApi\Contracts\SlackStar, (*25)
List all of starred itens., (*26)
Craftyx\SlackApi\Contracts\SlackTeam, (*27)
Get information about your team., (*28)
Craftyx\SlackApi\Contracts\SlackUser, (*29)
Get information about an user on your team or just check your presence ou status., (*30)
Craftyx\SlackApi\Contracts\SlackUserAdmin, (*31)
Invite new members to your team., (*32)
DBAD License., (*33)
Wrapper for Slack.com WEB API. Based on Vagner do Carmo one, but compatible with GuzzleHttp6
dbad
laravel lumen slack