PHP code example of adrian7 / mailchimp-api-v3

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

    

adrian7 / mailchimp-api-v3 example snippets


// $arguments is used as POST data or GET parameters, depending on the method used.
request($resource, $arguments = [], $method = 'GET')

get($resource, array $options = [])
head($resource, array $options = [])
put($resource, array $options = [])
post($resource, array $options = [])
patch($resource, array $options = [])
delete($resource, array $options = [])

$mc = new Mailchimp('<api-key>', '<guzzle-options[array]>');

// Get 10 lists starting from offset 10 and fset' => 10,
    'count' => 10
]);

// Will fire this query: 
// GET https://us1.api.mailchimp.com/3.0/lists?fields=lists.id,lists.name,lists.stats.member_count&count=10

var_dump($result);


// All these fields are sts', [
    'name' => 'New list',
    'permission_reminder' => 'You signed up for updates on mailchimp-api-v3.',
    'email_type_option' => false,
    'contact' => [
        'company' => 'Doe Ltd.',
		'address1' => 'DoeStreet 1',
		'address2' => '',
		'city' => 'Doesy',
		'state' => 'Doedoe',
		'zip' => '1672-12',
		'country' => 'US',
		'phone' => '55533344412'
    ],
    'campaign_defaults' => [
        'from_name' => 'John Doe',
        'from_email' => '[email protected]',
        'subject' => 'My new campaign!',
        'language' => 'US'
    ]
]);

$result = $mc->get('lists/e04d611199', [
    'fields' => 'id,name,stats.member_count'
]);

$mc->setProxy('https://127.0.0.1', 10, true, 'username', 'password');

$result = $mc->get('lists/e04d611199', [
    'fields' => 'id,name,stats.member_count'
]);