Webhooks PHP Dynamic Destinations
<?php
/**
* @param string $application_id
* @param string $customer_id
* @param string $bucket_key
* @param string $endpoint_url
* @param string $gateway
* @return string
*/
function convert($application_id, $customer_id, $bucket_key, $endpoint_url, $gateway = "gateway.webhooks.io")
{
// Split the endpoint_url using :// as the split location
$endpoint = explode("://", $endpoint_url);
return $endpoint[0] . "://" . $gateway . "/" . $application_id . "/" . $customer_id . "/" . $bucket_key . "/" . $endpoint[1];
}
// Example returns http://gateway.webhooks.io/application_id/customer_id/bucket_key/endpoint_url.com/incoming-webhook
echo (convert("application_id", "customer_id", "bucket_key", "http://endpoint_url.com/incoming-webhook"));