<?php require __DIR__ . '/../config.php'; $pdo=get_pdo(); $json=file_get_contents('php://input'); if(!$json){http_response_code(400);exit;} $msg=json_decode($json,true); if(!$msg){http_response_code(400);exit;} if(isset($msg['Type']) && $msg['Type']==='SubscriptionConfirmation'){ file_put_contents('sns_confirm.log', $msg['SubscribeURL']."\n", FILE_APPEND); echo 'ok'; exit;} if(isset($msg['Type']) && $msg['Type']==='Notification'){ $notification=json_decode($msg['Message'], true); if(isset($notification['bounce'])){ foreach($notification['bounce']['bouncedRecipients'] as $r){ $pdo->prepare('UPDATE list_contacts SET bounced=1 WHERE email=?')->execute([$r['emailAddress']]); } } if(isset($notification['complaint'])){ foreach($notification['complaint']['complainedRecipients'] as $r){ $pdo->prepare('UPDATE list_contacts SET unsubscribed=1 WHERE email=?')->execute([$r['emailAddress']]); } } echo 'ok'; exit;} echo 'noop';