Laravel框架使用松弛的交互式消息

时间:2017-06-30 10:43:14

标签: php json laravel slack slack-api

当我创建一个任务并应用假和时,laravel使用整合松弛在我的laravel应用程序中,它将在特定频道的松弛应用程序中收到消息 现在我正在使用Laravel 5.2并且也使用这个作曲家包(作曲家需要maknz / slack)但我无法显示交互式消息 这里是源代码

$settings = [
        'username'   => Auth::user()->name,
        'icon' => 'http://iosicongallery.com/img/512/slack-2014.png', 
        'link_names' => true   
      ];  
      $client = new \Maknz\Slack\Client('https://hooks.slack.com/services/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',$settings);
      $userslack = $client->attach([
          'fallback' => 'Fallback',
          'callback_id'=> 'game',
            'color' => 'danger',
            'attachment_type' => 'default',
            'fields' => [
                [
                    'title' => 'From Date',
                    'value' => $fr_date,
                    'short' => true 
                ],
                [
                    'title' => 'To Date',
                    'value' => $to_date,
                    'short' => true
                ],
                [
                    'title' => 'Reason',
                    'value' => $leave->description,
                    'short' => true
                ]
            ],
            'actions' => [
                [
                    'name' => 'leave',
                    'text' => 'Approved',
                    'style' => 'default',
                    'type' => 'button',
                    'value' => 'approve',
                    'confirm' => [
                        'title' => 'title1',
                        'text' => 'Your Leave Requested has been Approved',
                        'ok_text' => 'Yes',
                        'dismiss_text' => 'No',
                    ],
                ],
                [
                    'name' => 'leave',
                    'text' => 'Cancel',
                    'style' => 'default',
                    'type' => 'button',
                    'value' => 'cancel',
                    'confirm' => [
                        'title' => 'Title 2',
                        'text' => 'Your leave request is cancelled',
                        'ok_text' => 'No',
                        'dismiss_text' => 'No',
                    ],
                ],
            ],
      ])->send('Ofman Leave and Permission');

我需要在我的Slack应用程序中完全输出交互式消息,就像这个交互式消息示例截图

一样

https://a.slack-edge.com/dcb1/img/api/message_guidelines/Example_6.gif

提前致谢

0 个答案:

没有答案