【问题标题】:Send response to 2 webhooks via CURL通过 CURL 向 2 个 webhook 发送响应
【发布时间】:2022-09-25 08:01:45
【问题描述】:

我们在一个网站上有一个表单,该表单目前使用 Zapier Webhook 来捕获提交表单中的信息并将其推送到我们的 CRM。

如何向此表单添加另一个 webhook,以便在提交表单时它会同时命中两个端点?

在 Zapier 链中添加另一个步骤不是这里的选择。

    标签: php curl zapier


    【解决方案1】:

    不要依赖您的表单来同步请求,而是将请求发送到您的 API,并让它根据需要处理对相关 API 的后续请求。

    让表单仅捕获数据并将其发送到您的 API,并让 API 处理之后的步骤,这样您就可以减少客户端发生的问题,您可以更好地控制自己在 API 上处理数据。

    【讨论】:

    • 不幸的是,这不是一个选项,我们无法访问此表单点击的 Zapier 帐户或 Zapier 中的关联帐户。我知道这不是一个好习惯,但我只需要它来达到另一个端点。我将如何添加另一个 cURL 请求?
    【解决方案2】:

    您是否尝试过在 JS 中添加 onSubmit 函数? https://www.w3schools.com/jsref/event_onsubmit.asp

    您可以将其连接到表单,就像下面的 onClick 函数一样:

        <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Webhook</title>
      </head>
      <body>
        <button onclick="sendMessage()">Send</button>
      </body>
    
      <script>
        function sendMessage() {
          var request = new XMLHttpRequest();
          request.open("POST", "https://webhook");
    
          request.setRequestHeader('Content-type', 'application/json');
    
          var params = {
            username: "My Webhook Name",
            avatar_url: "",
            content: "The message to send"
          }
    
          request.send(JSON.stringify(params));
        }
      </script>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-03
      • 1970-01-01
      • 2020-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-28
      相关资源
      最近更新 更多