亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Slack 斜杠命令找不到觸發器 ID?

使用 Slack 斜杠命令找不到觸發器 ID?

PHP
胡說叔叔 2023-04-15 11:04:42
我的目標是能夠使用斜杠命令打開對話框并將反饋處理到數據庫中。我試圖讓對話框打開,但我收到有關斜杠命令的錯誤,其中顯示“未找到”。我的應用程序設置有 API 和適當的 OAuth。我使用我的 php 頁面的 url (domain.com/slash.php) 在我的應用程序中添加了一個斜杠命令斜杠命令使用以下代碼設置。當我從 slack 運行它時,我得到了輸出'{"ok":false,"error":"invalid_arguments","response_metadata":{"messages":["[ERROR] missing required field: trigger_id"]}}'我嘗試了一些調試并將trigger_id輸出到屏幕上,發現trigger_id確實為null。我錯過了什么才能通過這個?我承認我是松弛領域的新手。我已經按照(我認為)松弛網站上關于正確設置應用程序的文檔進行操作。我是否遺漏了我的松弛應用程序設置或我的代碼中導致此錯誤消息的內容?預先感謝您的寶貴時間!<?$command    = $_POST['command'];$text       = $_POST['text'];$token      = $_POST['token'];$cn         = $_POST['channel_id'];$user_id    = $_POST['user_id'];$triggerid  = $_POST['trigger_id'];// define the dialog for the user (from Slack documentation example)$dialog = [    'callback_id' => 'validres-3100',    'title' => 'Test',    'submit_label' => 'Submit',    'elements' => [        [            'type' => 'text',            'label' => 'Test Field 1',            'name' => 'field_1'        ],        [            'type' => 'text',            'label' => 'Test Field 2',            'name' => 'field_2'        ]    ]];// define POST query parameters$query = [        'token' => '<my api auth code>',        'dialog' => json_encode($dialog),        'trigger_id' => $triggerid];// define the curl request$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://slack.com/api/dialog.open');curl_setopt($ch, CURLOPT_HTTPHEADER, [        'Content-Type: application/x-www-form-urlencoded']);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);// set the POST query parameterscurl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));// execute curl request$response = curl_exec($ch);// closecurl_close($ch);var_export($response);?>
查看完整描述

1 回答

?
慕神8447489

TA貢獻1780條經驗 獲得超1個贊

要在 slack 中打開對話框,您可以使用此 api“?https://slack.com/api/views.open?”。使用 api,您需要發送僅在 3 秒內有效的觸發器 ID。?您的網址將類似于:?“?https://slack.com/api/views.open?trigger_id=?”+“xxxx.xxxxxxxxx.xxxxxxxxxxxx”+“&view=您的數據”。對于此請求,您需要在您的發布請求中發送令牌,例如:- (URL,"POST", { "token" ,"xoxb-xxxxxx-xxxxx-xxxxxxx"});

需要在您的 slack 應用程序中添加 view.open API 也為此使用以下步驟:?使用“Bot 用戶 OAuth 訪問令牌”,在“OAuth 和權限選項卡”中格式為 xoxb-xxxxx-xxxxx-xxxx。然后添加范圍“views:open”并重新安裝您的應用程序。然后嘗試打開視圖對話框。

希望這會有所幫助。


查看完整回答
反對 回復 2023-04-15
  • 1 回答
  • 0 關注
  • 143 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號