1. Go to this page and download the library: Download tatarko/yii-slack 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/ */
tatarko / yii-slack example snippets
'components' => array(
'slack' => array(
'class' => 'Tatarko\\YiiSlack\\ApplicationComponent',
'appId' => '', // Your's application ID
'appSecret' => '', // Your's application secret code
'tokenStateName' => 'slack.access.token'; // optional - change name of the user's state variable to store access token in
'companyToken' => '', // optional - set global access token of your company's account to use slack component without user authentication
),
)
class SiteController extends Controller
{
public function actions()
{
return array(
'slack' => array(
'class' => 'Tatarko\\YiiSlack\\AuthenticationAction',
'onAuthSuccess' => function(CEvent $event) {
// you can get $event->params->access_token and store it in some persistant database instead of user's states (that is basically sessions variable)
$this->redirect('welcome');
},
'onAuthError' => function(CEvent $event) {
// $event->params is instance of Exception (CException or GuzzleHttp\Exception\TransferException)
$this->redirect('login');
},
),
);
}
}