mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 06:40:33 -04:00
Pull out apcu code into a function to improve error handling
This commit is contained in:
parent
0bf50873ac
commit
beda605f32
4 changed files with 43 additions and 60 deletions
|
@ -12,6 +12,8 @@ use function Safe\substr;
|
|||
$requestId = substr(sha1(time() . rand()), 0, 8);
|
||||
|
||||
try{
|
||||
$smtpUsername = trim(file_get_contents(POSTMARK_SECRET_FILE_PATH)) ?: '';
|
||||
|
||||
Logger::WritePostmarkWebhookLogEntry($requestId, 'Received Postmark webhook.');
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] != 'POST'){
|
||||
|
@ -50,7 +52,7 @@ try{
|
|||
$handle = curl_init();
|
||||
curl_setopt($handle, CURLOPT_URL, 'https://api.postmarkapp.com/message-streams/' . $post->MessageStream . '/suppressions/delete');
|
||||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($handle, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Accept: application/json', 'X-Postmark-Server-Token: ' . EMAIL_SMTP_USERNAME]);
|
||||
curl_setopt($handle, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Accept: application/json', 'X-Postmark-Server-Token: ' . $smtpUsername]);
|
||||
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($handle, CURLOPT_POSTFIELDS, '{"Suppressions": [{"EmailAddress": "' . $email . '"}]}');
|
||||
curl_exec($handle);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue