PHP code example of doowebdev / mailchimp-api

1. Go to this page and download the library: Download doowebdev/mailchimp-api 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/ */

    

doowebdev / mailchimp-api example snippets


"doowebdev/mailchimp-api": "dev-master"



use Doowebdev\MailChimpApi;

use Doowebdev\MailChimpApi;

class SomeClass
{

    public function someMethod()
    {
        $mc = new MailChimpApi('YOUR-MAILCHIMP-APIKEY-GOES-HERE');

       //We are using the 'lists/subscribe' method to subscribe a user/visitor to our newsletter list.
        $results = $mc->run('lists/subscribe',[
            'id'                => 'YOUR-LIST-ID-GOES-HERE',
            'email'             => ['email'=>'[email protected]'],
            'merge_vars'        => ['FNAME'=>'subscribers_firstname', 'LNAME'=>'subscribers_lastname'],
            'double_optin'      => true,
            'update_existing'   => true,
            'replace_interests' => false,
            'send_welcome'      => true,
        ]);

        var_dump($results);
    }

}