PHP code example of mocean / mailchimp

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

    

mocean / mailchimp example snippets


'MOCEAN_API_VERSION' => '1',
'MOCEAN_API' => 'rest.moceanapi.com/rest',
'MOCEAN_API_KEY' => '',
'MCOEAN_API_SECRET' => '',
'MOCEAN_API_SENDER_ID' => '', //for mocean-from field (leave empty to use mailchimp list name as sender id)
'MOCEAN_API_TEXT' => 'Testing Text',

'MAILCHIMP_API_VERSION' => '3.0',
'MAILCHIMP_API' => 'api.mailchimp.com',
'MAILCHIMP_API_KEY' => '',
'MAILCHIMP_LISTS_SEARCH_NAME' => '', //search for mailchimp list to be used (leave this empty to use all lists)
'MAILCHIMP_CAMPAIGNS_SEARCH_TITLE' => '', //search for campaign title to be used (leave this empty to use all campaigns)

'ALLOW_DUPLICATE_MEMBER' => false, //set to true if the you wish to send to the same member in different list multiple time



$config = array(
    'MOCEAN_API_KEY' => 'xxxx',
    'MCOEAN_API_SECRET' => 'xxxx',
    'MOCEAN_API_TEXT' => 'Testing Text',
    
    'MAILCHIMP_API_KEY' => 'xxxx-xxx',
);

$mailchimp = new Mocean\Mailchimp\Mailchimp($config);

$totalSmsSent = $mailchimp->campaigns()->lists()->members()->broadcast();
echo "Total SMS Sent: $totalSmsSent";

$totalSmsSent = $mailchimp->lists()->members()->broadcast();
echo "Total SMS Sent: $totalSmsSent";

broadcast('custom text');

//seperate multiple name by (,)
$config => array(
    'MAILCHIMP_LISTS_SEARCH_NAME' => 'First List,Second List',
    'MAILCHIMP_CAMPAIGNS_SEARCH_TITLE' => 'First Campaign,Second Campaign',
);

$campaignResponse = $mailchimp->campaigns()->get();
$listResponse = $mailchimp->lists()->get();
$memberResponse = $mailchimp->lists()->members()->get();

$mailchimp->setConfig($config);

$campaigns = $mailChimp->campaigns();
if($campaigns === false){
    echo Mocean\Mailchimp\api\MailChimpApi::$errMsg;
}