PHP code example of insidieux / slack-api

1. Go to this page and download the library: Download insidieux/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/ */

    

insidieux / slack-api example snippets


$client = new \SlackApi\Client('your-token-here');

$client = new \SlackApi\Client('your-token-here');
$response = $client->request('module.method', ['argument' => 'value']);
$response->toArray();

$client = new \SlackApi\Client('your-token-here');
$response = $client->users()->getList();
$response->toArray()

$client = new \SlackApi\Client('your-token-here');
$message = new \SlackApi\Models\Message($client);

$client = new \SlackApi\Client('your-token-here');
$message = $client->makeMessage();

$data = [
    'fallback' => 'Some fallback'
    'pretext'  => 'Some pretext',
    'text'     => 'good',
    'text'     => 'Some text'
]; 
$attachment1 = new \SlackApi\Models\Attachment($data);

$attachment2 = new \SlackApi\Models\Attachment;
$attachment2->setText('Some text')
    ->setColor(\SlackApi\Models\Attachment::COLOR_GOOD)
    ->setFallback('Some fallback');

$field = new \SlackApi\Models\AttachmentField;
$field->setShort(false)
    ->setTitle('Field title')
    ->setValue('Field value');
$attachment->addField($field);

$message->attach($attachment);

$response = $message->send();
$response->toArray()