是否可以配置发送网格帐户,以便我可以指定多个发布事件 URL 事件通知。或者也许可以添加多个事件通知应用程序?
目前无法将事件 Webhook POST 事件发送到多个 URL。
您可以编写一个脚本,将数据重新发布到您想要的任意数量的 URL,并指示 SendGrid 对其进行 POST。例如用 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);
编辑: 现在建议您使用 Reflector.io(另一个 SendGrid 产品)将 Webhook 发送到多个目的地。
我也面临类似的问题。就我而言,我必须更新各种环境(例如阶段/产品)。
我选择pub/sub模型。
在 sendgrid 下(邮件设置 > Web 挂钩): 我为我的主题添加了发布者网址。