1. Go to this page and download the library: Download craftyx/slack-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
//Lists all users on your team
SlackUser::lists(); //all()
//Lists all channels on your team
SlackChannel::lists(); //all()
//List all groups
SlackGroup::lists(); //all()
//Invite a new member to your team
SlackUserAdmin::invite("[email protected]", [
'first_name' => '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();
namespace App\Http\Controllers;
use Craftyx\SlackApi\Contracts\SlackUser;
class YourController extends Controller{
/** @var SlackUser */
protected $slackUser;
public function __construct(SlackUser as $slackUser){
$this->slackUser = $slackUser;
}
public function controllerMethod(){
$usersList = $this->slackUser->lists();
}
}