<?php // called by aws sns with json payload for subscribe sns or complaint email // can't be called on the dev environment if ($_SERVER['REQUEST_METHOD'] != 'POST') { exit; } $post = file_get_contents('php://input'); require_once '../../phpinclude/snsverify.php'; if (!verify_sns($post, $_SERVER['AWS_DEPLOYREGION'], $_SERVER['AWS_ACCOUNT'], array('EmailComplaint'))) { exit; } $msg = json_decode($post, true); if ($msg['Type'] == 'SubscriptionConfirmation') { // need to visit SubscribeURL $surl = $msg['SubscribeURL']; $curlOptions = array(CURLOPT_URL => $surl, CURLOPT_VERBOSE => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => TRUE, CURLOPT_SSL_VERIFYHOST => 2); $ch = curl_init(); curl_setopt_array($ch, $curlOptions); $response = curl_exec($ch); if (curl_errno($ch)) { $errors = curl_error($ch); curl_close($ch); echo $errors; } else { curl_close($ch); echo $response; } exit; } elseif ($msg['Type'] == 'Notification') { // init db
<?php // called by aws sns with json payload for subscribe sns or bounced email // can't be called on the dev environment if ($_SERVER['REQUEST_METHOD'] != 'POST') { exit; } $post = file_get_contents('php://input'); require_once '../../phpinclude/snsverify.php'; if (!verify_sns($post, $_SERVER['AWS_DEPLOYREGION'], $_SERVER['AWS_ACCOUNT'], array('EmailBounce'))) { exit; } $msg = json_decode($post, true); if ($msg['Type'] == 'SubscriptionConfirmation') { // need to visit SubscribeURL $surl = $msg['SubscribeURL']; $curlOptions = array(CURLOPT_URL => $surl, CURLOPT_VERBOSE => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => TRUE, CURLOPT_SSL_VERIFYHOST => 2); $ch = curl_init(); curl_setopt_array($ch, $curlOptions); $response = curl_exec($ch); if (curl_errno($ch)) { $errors = curl_error($ch); curl_close($ch); echo $errors; } else { curl_close($ch); echo $response; } exit; } elseif ($msg['Type'] == 'Notification') { // init db