Skip to main content

After being extremely aggravated with the documentation and lack of it when it comes to a simple question for someone who writes code all day, I decided to post this as I see bunches of unanswered (and poorly answered) questions up here.

 

THE ANSWER:

Use this PHP code to send data to a Catch Hook in Webhooks by Zapier

https://stackoverflow.com/questions/73214553/how-to-send-php-form-post-data-to-zapier-webhook-solution/73214554#73214554

//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 $_POSTO'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

Here are all the questions I wanted answered that should have taken me all of 10 seconds to find and should have been on this page:

 https://zapier.com/help/create/code-webhooks/trigger-zaps-from-webhooks 

https://zapier.com/help/create/code-webhooks/send-webhooks-in-zaps

 

Keyword stuffing:

  • How to send PHP form data to Zapier webhook
  • PHP method to send POST data from form to Zapier webhook
  • Send POST data or JSON to Zapier webhook
  • Posting directly to Zapier from PHP
  • Trigger Zaps from webhooks in PHP
  • zapier webhook send php
  • Send webhook zap in PHP POST data
  • Does Zapier webhook accept POST data?
  • Should I send PHP Zapier webhook as JSON?
  • Do I need to use CURL or http_build_query to send data to Zapier webhook?

 

Which should be the answer IMHO to every single one of these

https://stackoverflow.com/questions/18483158/posting-curl-to-zapier-webhook