PHP code example of aelvan / mailchimp-subscribe

1. Go to this page and download the library: Download aelvan/mailchimp-subscribe library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aelvan / mailchimp-subscribe example snippets


use aelvan\mailchimpsubscribe\events\SubscribeEvent;
use aelvan\mailchimpsubscribe\services\MailchimpSubscribeService;

Event::on(
    MailchimpSubscribeService::class,
    MailchimpSubscribeService::EVENT_AFTER_SUBSCRIBE,
    function (SubscribeEvent $event) {
        // custom logic
    }
);

use aelvan\mailchimpsubscribe\events\UnsubscribeEvent;
use aelvan\mailchimpsubscribe\services\MailchimpSubscribeService;

Event::on(
    MailchimpSubscribeService::class,
    MailchimpSubscribeService::EVENT_AFTER_UNSUBSCRIBE,
    function (UnsubscribeEvent $event) {
        // custom logic
    }
);

use aelvan\mailchimpsubscribe\events\DeleteEvent;
use aelvan\mailchimpsubscribe\services\MailchimpSubscribeService;

Event::on(
    MailchimpSubscribeService::class,
    MailchimpSubscribeService::EVENT_AFTER_DELETE,
    function (DeleteEvent $event) {
        // custom logic
    }
);

[
    0 => stdClass#1
    (
        [marketing_permission_id] => '0e963d96x1'
        [text] => 'Weekly newsletter'
        [enabled] => true
    )
    1 => stdClass#2
    (
        [marketing_permission_id] => '42723a122x'
        [text] => 'Special offers'
        [enabled] => false
    )
    2 => stdClass#3
    (
        [marketing_permission_id] => '36cxbd1a8b'
        [text] => 'Special offers from partners'
        [enabled] => false
    )
]
 
$response = $msPlugin->mailchimpSubscribe->delete('[email protected]', '2a34d0978q', true);