# acymailing/10.0.1/back/dynamics/sendinblue/webhooks.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version 10.0.1. 43 lines.

- Page: https://pluginprobe.com/plugins/acymailing/10.0.1/code/back/dynamics/sendinblue/webhooks.php
- Raw: https://pluginprobe.com/plugins/acymailing/10.0.1/raw/back/dynamics/sendinblue/webhooks.php
- Modified: 2022-05-02T07:17:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/10.0.1/code/back/dynamics/sendinblue/webhooks.php#L10-L20`.

```php
<?php

class SendinblueWebhooks extends SendinblueClass
{
    public function addWebhooks()
    {
        $sendingMethod = $this->config->get('mailer_method', 'phpmail');
        if ($sendingMethod != plgAcymSendinblue::SENDING_METHOD_ID) return;

        $webhooks = $this->config->get(plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_added');
        if (!empty($webhooks)) return;

        $securityKey = $this->config->get(plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_seckey');
        if (empty($securityKey)) {
            $securityKey = acym_generateKey(40);
            $this->config->save([plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_seckey' => $securityKey]);
        }

        $types = ['transactional', 'marketing'];

        $webhooks = [];
        foreach ($types as $type) {
            $response = $this->callApiSendingMethod(
                'webhooks?type='.$type,
                [
                    'events' => ['hardBounce', 'spam', 'unsubscribed'],
                    'type' => $type,
                    'url' => acym_frontendLink('frontservices&task=sendinblue&seckey='.$securityKey),
                    'description' => 'Disable users in AcyMailing',
                ],
                $this->headers,
                'POST'
            );

            if (!empty($response['id'])) {
                $webhooks[$type] = $response['id'];
            }
        }

        $this->config->save([plgAcymSendinblue::SENDING_METHOD_ID.'_webhooks_added' => json_encode($webhooks)]);
    }
}

```
