<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
locomotivemtl / charcoal-contrib-mailchimp example snippets
class FooBar
{
use MailchimpAwareTrait;
[...]
public function setDependencies(Container $container)
{
$this->setMailchimpListsMembers($container['mailchimp/lists/members']);
[...]
}
public function run()
{
$user = [
'email_address' => '[email protected]',
'status' => 'pending',
'merge_fields' => [
'FNAME' => 'John',
'LNAME' => 'Doe'
]
];
// Set list ID
$listId = 'a4029db2d';
$this->mailchimpListsMembers()->setListId($listId);
// Add/Create user
$results = $this->mailchimpListsMembers()->add($user);
// Add or Update user
$results = $this->mailchimpListsMembers()->addOrUpdate($user);
// Get a user's informations
$results = $this->mailchimpListsMembers()->get('[email protected]');
// Delete a user from a list
$results = $this->mailchimpListsMembers()->remove('[email protected]');
}
}
// Get lists members
$this->mailchimp()->get('lists/{list_id}/members');
// Add member to list
$this->mailchimp()->post('list/{list_id}/members', [
'email_address' => '[email protected]',
'status' => 'pending'
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.