PHP code example of chimpmatic / mailchimp-audience-finder
1. Go to this page and download the library: Download chimpmatic/mailchimp-audience-finder 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/ */
chimpmatic / mailchimp-audience-finder example snippets
use Chimpmatic\AudienceFinder\AudienceFinder;
$finder = new AudienceFinder('your-api-key-us4');
// Get all audiences
$audiences = $finder->findAll();
foreach ($audiences as $audience) {
echo $audience->id; // "abc123def4"
echo $audience->name; // "Newsletter Subscribers"
echo $audience->memberCount; // 1500
echo $audience->doubleOptIn; // true
// Merge fields included automatically
foreach ($audience->mergeFields as $field) {
echo $field->tag; // "FNAME"
echo $field->name; // "First Name"
echo $field->type; // "text"
echo $field->
$audience = $finder->findByName('newsletter');
// Case-insensitive partial match — returns first match or null
$audience = $finder->findById('abc123def4');
// Find a specific field
$fname = $audience->getMergeFieldByTag('FNAME');
echo $fname->name; // "First Name"
echo $fname->getMergeTag(); // "*|FNAME|*"
// Get all