1. Go to this page and download the library: Download threadmeup/slack-sdk 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/ */
threadmeup / slack-sdk example snippets
use ThreadMeUp\Slack\Client;
$config = [
'token' => 'USER-API-TOKEN',
'team' => 'YOUR-TEAM',
'username' => 'BOT-NAME',
'icon' => 'ICON', // Auto detects if it's an icon_url or icon_emoji
'parse' => '', // __construct function in Client.php calls for the parse parameter
];
$slack = new Client($config);
$incoming = $slack->listen();
if ($incoming)
{
switch($incoming->text())
{
case "What time is it?":
$incoming->respond("It is currently ".date('g:m A T'));
break;
default:
$incoming->respond("I don't understand what you're asking.");
break;
}
}
$payload = [
'token' => 'YNgeXsCXyWgAMfCvjc7NUUpz',
'team_id' => 'T0001',
'channel_id' => 'C2147483705',
'channel_name' => 'test',
'timestamp' => '1355517523.000005',
'user_id' => 'U2147483697',
'user_name' => 'Steve',
'text' => 'googlebot: What is the air-speed velocity of an unladen swallow?'
];
$incoming = $slack->listen($payload);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.