Skip to content

Instantly share code, notes, and snippets.

@garethtdavies
Last active April 12, 2016 20:53
Show Gist options
  • Save garethtdavies/11db31e45904295b9ff71e3173e554d0 to your computer and use it in GitHub Desktop.
Save garethtdavies/11db31e45904295b9ff71e3173e554d0 to your computer and use it in GitHub Desktop.
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"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment