I’m having trouble sending data to a Zapier webhook using PHP cURL. The webhook works fine when I access it directly through the browser with GET parameters, but my PHP cURL POST request isn’t working.
Here’s my current PHP code:
<?php
// Set up cURL session
$ch = curl_init();
// Build POST data string
$postData = 'user_id=' . $_POST['user_id'] . '&title=' . $_POST['title'] . '&user_email=' . $_POST['user_email'];
// Configure cURL settings
$options = array(
CURLOPT_URL => 'https://zapier.com/hooks/catch/n/xyz123',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
)
);
// Apply settings
curl_setopt_array($ch, $options);
// Execute request
$response = curl_exec($ch);
// Clean up
curl_close($ch);
print $response;
?>
The script runs without errors and shows a success message, but Zapier doesn’t receive the data. I noticed that Zapier’s documentation shows JSON format for POST requests. Should I be sending JSON data instead of form-encoded data? What am I missing in my implementation?