【问题标题】:How to send PHP FORM POST data to Zapier webhook: SOLUTION如何将 PHP FORM POST 数据发送到 Zapier webhook:解决方案
【发布时间】:2022-08-03 06:46:44
【问题描述】:

在对 ZAPIER 文档感到非常恼火并且在谈到一个简单的问题时缺乏它之后,我决定发布这个,因为我在 Zapier 的社区上看到了一堆未回答(并且回答不佳)的问题。

关键字填充:

  • 如何将 PHP 表单数据发送到 Zapier webhook
  • 将 POST 数据从表单发送到 Zapier webhook 的 PHP 方法
  • 向 Zapier webhook 发送 POST 数据或 JSON
  • 从 PHP 直接发布到 Zapier
  • 从 PHP 中的 webhook 触发 Zaps
  • zapier webhook 发送 php
  • 在 PHP POST 数据中发送 webhook zap
  • Zapier webhook 是否接受 POST 数据?
  • 我应该将 PHP Zapier webhook 作为 JSON 发送吗?
  • 是否需要使用 CURL 或 http_build_query 将数据发送到 Zapier webhook?

    标签: php webhooks zapier


    【解决方案1】:

    答案:

    使用此 PHP 代码将数据发送到 Zapier 的 Webhooks 中的 Catch Hook

    只需将表单中的 PHP 发布数据填充到 http_build_query 并将其卷曲到 webhook url。完毕。

    //first off, set up all my post data
    if(is_array($_POST)){ foreach ($_POST as $key => $value) { ${$key} = $value; } }
    
    // now all my  post data is available as PHP vars
    //(matching my html form input names)
    // <input name=first_name 
    // then ->becomes  $_POST['first_name'] 
    // then ->becomes var $first_name;
    
    // now rename and assign vars
    $_ZAP_ARRAY = array(
        "test_var_1" => "test data",
        "test_var_2" => "test data bbb",
        "test_var_3" => "test data ccc",
        "test_var_4" => "test ddd",
        "set_your_var_here" => $set_post_data_here, 
        "zap_f_name" => $first_name /
    );
    
    // stuff it into a query
    $_ZAP_ARRAY = http_build_query($_ZAP_ARRAY );
    
    // get my zap URL
    $ZAPIER_HOOK_URL = "https://hooks.zapier.com/hooks/catch/000000/xxxxxx/"
    
    // curl my data into the zap
    $ch = curl_init( $ZAPIER_HOOK_URL);
    curl_setopt( $ch, CURLOPT_POST, 1);
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $_ZAP_ARRAY);
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt( $ch, CURLOPT_HEADER, 0);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
    
    $response = curl_exec( $ch );
    // done
    

    恕我直言,应该在这些页面上:

    【讨论】:

      猜你喜欢
      • 2019-07-17
      • 2019-01-18
      • 2019-05-01
      • 2013-08-31
      • 2020-06-23
      • 1970-01-01
      • 2018-07-23
      • 2016-01-26
      • 2018-10-11
      相关资源
      最近更新 更多