dongpo2014 2018-02-14 10:48
浏览 74

Slack Dialog出错

I am working on a small slack app development. I stuck in one situation. I am using slack dialog to get data from the user and when user enter data and click on submit button I get an alert message. I don't know what is it and why it gives an alert. What to do with this? Please note I get payload response in my interactive component script. And respond to the server with 200. Here is my Response code :

 if($type == "dialog_submission")
 {
         http_response_code(200);
         return json_encode(array(
             'status' => 200,
             'message' => 'ok'
        ));

   $ch = curl_init("https://slack.com/api/chat.postMessage");
   $dataSet = http_build_query([
   "token" => $authToken,
   "channel" => $data['channel']['name'],
   "text" => "123",
   ]);

   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
   curl_setopt($ch, CURLOPT_POSTFIELDS, $dataSet);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
   $result = curl_exec($ch);
   curl_close($ch);

   echo $result;

    }

Screenshot of alert message

  • 写回答

2条回答 默认 最新

  • doulifang5554 2018-02-14 11:06
    关注

    You need to return an empty response to the Slack Dialog, or you will get the error

    We had some trouble connecting. Try again?

    So you must somewhere have an echo that returns something to the Slack dialog causing the error. You need to remove those. Like the echo $result; at the end.

    This error will also occur if your script has a run-time error, since it will then create an automatic response like "error in test.php line 101....". To check for that make sure you have error logging activated and check if there are any errors in the logfile.

    You activate error logging by putting these commands at the beginning of your script:

    ini_set("log_errors", 1);
    ini_set("error_log", "php-errors.log");
    

    You can however return validation errors to Slack, but those must be in a specific format. See this documentation for details.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog