-
Notifications
You must be signed in to change notification settings - Fork 0
Audience Operations
With this plugin, we will only get List / Audience of the subscriber's Mailchimp account.
# List / Audience API access: Mailchimp Lists
Authorization: API key
Get information about all lists
GET https://<dc>.api.mailchimp.com/3.0/lists/'
Get information about all lists
GET'https://<dc>.api.mailchimp.com/3.0/lists/{list_id}
Once we are able to retrieve the List details, we will need to get the List/Audience ID to be saved in our custom fields.
Sample Code for Free Accounts
use \DrewM\MailChimp\MailChimp;
$mailchimp_account = $MailChimp->get("/", $clientSecret);
$account_type = json_encode($mailchimp_account['pricing_plan_type']);
$account_type = str_replace('"', '', $account_type);
if ($account_type == 'forever_free') {
$mailchimp_list = $MailChimp->get("lists", $clientSecret);
foreach($mailchimp_list['lists'] as $lists) {
$name = $lists['name'];
$audience_id = $lists['id'];
}