Can I specify multiple endpoints for notification of Sendgrid events?

Is it possible to set up a grid mesh account so that I can specify multiple event notifications for the Post Event URL. Or maybe you can add multiple event notification applications?

+6
source share
1 answer

There is currently no way to have POST events of Webhook events for multiple URLs.

You can write a script that will forward data to as many URLs as you need and direct SendGrid to POST. For example, written in PHP:

// An array of the URLs you want to POST to: $urls = array("http://mylocation1.com/event", "http://mylocation2.com/event"); $multi_handle = curl_multi_init(); $handles = array(); // Loop through each URL and create a cURL Handle for the URL // The cURL handle will POST data that comes to this script to the url. foreach ($urls as $key => $url) { $handles[$key] = curl_init(); curl_setopt($handles[$key], CURLOPT_URL, $url); curl_setopt($handles[$key], CURLOPT_POST, 1); curl_setopt($handles[$key], CURLOPT_POSTFIELDS, $_POST); curl_setopt($handles[$key], CURLOPT_RETURNTRANSFER, true); curl_multi_add_handle($multi_handle, $handles[$key]); } $running = null; // Run through each cURL handle and execute it. do { curl_multi_exec($multi_handle, $running); } while ($running); curl_multi_close($multi_handle); 

EDIT: Now you are advised to use Reflector.io (another SendGrid product) to send a website for multiple destinations.

+8
source

Source: https://habr.com/ru/post/952365/


All Articles