PHP code example of lisennk / laravel-slack-web-api

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

    

lisennk / laravel-slack-web-api example snippets


  // ...
  
  'providers' => [
    // ...
    // A whole bunch of providers
    // ...
    
    \Lisennk\Laravel\SlackWebApi\Providers\SlackApiServiceProvider::class
  ],
  
  // ...

  // ...
  
  'aliases' => [
    // ...
    // A whole bunch of aliases
    // ...
    
    'SlackApi' => \Lisennk\Laravel\SlackWebApi\Facades\SlackApi::class
  ],
  
  // ...

'token' => 'your-token-here'

$api->execute('method.name', [
  'parameter_one' => 'some-data',
  'parameter_two' => 'some-other-data'
  // ...
];

use \Lisennk\Laravel\SlackWebApi\SlackApi;
use \Lisennk\Laravel\SlackWebApi\Exceptions\SlackApiException;

// ...

public function postMessage(SlackApi $api)
{
  try {
    $response = $api->execute('users.info', [
      'user' => 'U1234567890'
    ]);
    $name = $response['user']['name'];
    // Do something amazing with data from Slack...
  } catch (SlackApiException $e) {
    return 'Error:' . $e->getMessage();
  }
}

// ...

use \Lisennk\Laravel\SlackWebApi\Exceptions\SlackApiException;

// ...

public function postMessage()
{
  try {
    $response = SlackApi::execute('users.info', [
      'user' => 'U1234567890'
    ]);
    $name = $response['user']['name'];
    // Do something amazing with data from Slack...
  } catch (SlackApiException $e) {
    return 'Error:' . $e->getMessage();
  }
}

// ...
bash
php artisan vendor:publish