PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / trunk
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress vtrunk
11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 10.3.0 10.4.0 All 60 releases
acymailing / back / dynamics / sendinblue / webhooks.php

webhooks.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress trunk, at back/dynamics/sendinblue/webhooks.php

43 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class SendinblueWebhooks extends SendinblueClass
4 {
5 public function addWebhooks()
6 {
7 $sendingMethod = $this->config->get('mailer_method', 'phpmail');
8 if ($sendingMethod != plgAcymSendinblue::SENDING_METHOD_ID) return;
9
10 $webhooks = $this->config->get(plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_added');
11 if (!empty($webhooks)) return;
12
13 $securityKey = $this->config->get(plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_seckey');
14 if (empty($securityKey)) {
15 $securityKey = acym_generateKey(40);
16 $this->config->saveConfig([plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_seckey' => $securityKey]);
17 }
18
19 $types = ['transactional', 'marketing'];
20
21 $webhooks = [];
22 foreach ($types as $type) {
23 $response = $this->callApiSendingMethod(
24 'webhooks?type='.$type,
25 [
26 'events' => ['hardBounce', 'spam', 'unsubscribed'],
27 'type' => $type,
28 'url' => acym_frontendLink('frontservices&task=sendinblue&seckey='.$securityKey),
29 'description' => 'Disable users in AcyMailing',
30 ],
31 $this->headers,
32 'POST'
33 );
34
35 if (!empty($response['id'])) {
36 $webhooks[$type] = $response['id'];
37 }
38 }
39
40 $this->config->saveConfig([plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_added' => json_encode($webhooks)]);
41 }
42 }
43