PHP code example of christianezeani / mailchimp

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

    

christianezeani / mailchimp example snippets




return [
  ...
  
  "providers" => [
    ...
    MailChimp\Framework\Laravel\MailChimpServiceProvider::class
  ]

  ...
];




use MailChimp\Config;
use MailChimp\MailChimp;
use MailChimp\Models\Lists\Audience;

$config = new Config('_your_api_key_');
$mailChimp = new MailChimp($config);

$audience = $mailChimp->audience();

$audience->create([
  'name' => 'MailChimp Test',
  'contact' => [
    'company' => 'Demo Company Inc.',
    'address1' => 'Just a demo address',
    'city' => 'Nnewi South',
    'state' => 'Anambra',
    'zip' => '23401',
    'country' => 'Nigeria',
    'phone' => '+2347000000000'
  ],
  'permission_reminder' => 'Demo permission reminder',
  'campaign_defaults' => [
    'from_name' => 'Christian Ezeani',
    'from_email' => '[email protected]',
    'subject' => 'Demo Subject',
    'language' => 'en'
  ],
  'email_type_option' => false,
  'visibility' => 'prv'
]);