複数の Post Event URL イベント通知を指定できる送信グリッド アカウントを構成することは可能ですか。または、複数のイベント通知アプリを追加することは可能ですか?
質問する
4565 次
1 に答える
15
現在、Events 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);
編集: Webhook を複数の宛先に送信するには、 Reflector.io (別の SendGrid 製品) を使用することをお勧めします。
于 2013-08-23T17:42:44.257 に答える