Reputation: 1237
After being extremely aggravated with the ZAPIER documentation and lack of it when it comes to a simple question I decided to post this as I see bunches of unanswered (and poorly answered) questions on Zapier's community.
Keyword stuffing: all of these should have returned answers in google.
THE ANSWER:
Use this PHP code to send data to a Catch Hook in Webhooks by Zapier
Simply stuff the PHP post data from your form into http_build_query and curl it over to the webhook url. done.
//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
IMHO should have been on these pages:
Upvotes: 2
Views: 3627
Reputation: 1237
THE ANSWER:
Use this PHP code to send data to a Catch Hook in Webhooks by Zapier
Simply stuff the PHP post data from your form into http_build_query and curl it over to the webhook url. done.
//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
IMHO should have been on these pages:
Upvotes: 2