2017 © Pedro PelĆ”ez
 

library zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

image

zfr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  • Thursday, November 24, 2016
  • by bakura10
  • Repository
  • 9 Watchers
  • 45 Stars
  • 496,750 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 25 Forks
  • 4 Open issues
  • 16 Versions
  • 14 % Grown

The README.md

ZfrMailChimp, a MailChimp PHP Library

Latest Stable Version, (*1)

IMPORTANT: MailChimp has announced the removal of old API (including v1 and v2) in their blog post. Because this library is based on v2, it will stop working at the end of the year. I don't have the time to update this library to the v3 as today, but if anyone would like to tackle it... do not hesitate!, (*2)

Note : this library does not contain tests, mainly because I'm not sure about how to write tests for an API wrapper. Don't hesitate to help on this ;-)., (*3)

Introduction

This is an unofficial MailChimp PHP client for interacting with the v2 REST MailChimp API. If you are looking for a wrapper around previous MailChimp API versions (like 1.3), please refer to something else., (*4)

What is done

The following methods are supported by the client (not everything has been carefully tested though):, (*5)

  • Campaign related methods (complete)
  • Ecomm related methods (complete)
  • Vip related methods (complete)
  • Folder related methods (complete)
  • Users related methods (complete)
  • Report related methods (only main methods)
  • Templates related methods (complete)
  • List related methods (nearly complete)
  • Gallery related methods (complete)
  • Helper related methods (partially complete)

Dependencies

Integration with frameworks

To make this library even more easier to use, here are various frameworks integrations:, (*6)

Want to do an integration for another framework? Open an issue, and I'll open a repository for you!, (*7)

Installation

We recommend you to use Composer to install ZfrMailChimp:, (*8)

php composer.phar require zfr/zfr-mailchimp:2.*

Tutorial

Firstly, you need to instantiate the MailChimp client:, (*9)

$client = new MailChimpClient('my-api-key');

The correct endpoint will be automatically chosen based on your API key., (*10)

You can then have access to all the methods available (see the list below):, (*11)

// Get activity about a list
$activity = $client->getListActivity(array(
    'id' => 'list-id'
));

// Add a new folder
$client->addFolder(array(
    'name' => 'my-folder-name',
    'type' => 'template'
));

How to use it ?

You will notice that the method names below does not always have a 1-to-1 mapping with the API names. For instance, most methods that imply retrieving something are prefixed by "get"., (*12)

However, there is an exact mapping for parameters. Therefore, you just need to refer to the official documentation for a given method (links are given below). Here is an example with the subscribe method:, (*13)

$client->subscribe(array(
    'id' => 'list-id',
    'email' => array(
        'email' => 'example@foo.com',
        'euid'  => '1545d'
    )
));

Exceptions handling

ZfrMailChimp tries its best to extract meaningful exceptions from MailChimp errors. All exceptions implement the ZfrMailChimp\Exception\ExceptionInterface interface, so you can use this to do a catch all block. You can find an exhaustive list of all exceptions in the ZfrMailChimp\Exception folder., (*14)

List exceptions are under the Ls namespace, because list is a reserved keyword in PHP., (*15)

Usage example:, (*16)

try {
    $client->subscribe(array(
        'id' => 'list-id',
        'email' => array(
            'email' => 'example@foo.com',
            'euid'  => '1545d'
        )
    ));
} catch (\ZfrMailChimp\Exception\Ls\AlreadySubscribedException $e) {
    $message = $e->getMessage();

    // You can do something interesting here!
} catch(\ZfrMailChimp\Exception\Ls\DoesNotExistException $e) {
    // Do something else useful!
}
catch (\ZfrMailChimp\Exception\ExceptionInterface $e) {
    // Any other exception that may occur
}

Complete reference

Here are the supported methods today:, (*17)

CAMPAIGN RELATED METHODS:, (*18)

  • array createCampaign(array $args = array()) doc
  • array deleteCampaign(array $args = array()) doc
  • array getCampaignContent(array $args = array()) doc
  • array getCampaigns(array $args = array()) doc
  • array getTemplateContent(array $args = array()) doc
  • array pauseCampaign(array $args = array()) doc
  • array replicateCampaign(array $args = array()) doc
  • array resumeCampaign(array $args = array()) doc
  • array scheduleCampaign(array $args = array()) doc
  • array scheduleBatchCampaign(array $args = array()) doc
  • array sendCampaign(array $args = array()) doc
  • array sendTestCampaign(array $args = array()) doc
  • array testSegmentation(array $args = array()) doc
  • array unscheduleCampaign(array $args = array()) doc
  • array updateCampaign(array $args = array()) doc

LIST RELATED METHODS:, (*19)

  • array addInterestGroup(array $args = array()) doc
  • array addInterestGrouping(array $args = array()) doc
  • array addListMergeVar(array $args = array()) doc
  • array addListSegment(array $args = array()) doc
  • array addListWebhook(array $args = array()) doc
  • array addStaticListSegment(array $args = array()) doc
  • array addStaticSegmentMembers(array $args = array()) doc
  • array batchSubscribe(array $args = array()) doc
  • array batchUnsubscribe(array $args = array()) doc
  • array deleteInterestGroup(array $args = array()) doc
  • array deleteInterestGrouping(array $args = array()) doc
  • array deleteListMergeVar(array $args = array()) doc
  • array deleteListSegment(array $args = array()) doc
  • array deleteListWebhook(array $args = array()) doc
  • array deleteStaticSegmentMembers(array $args = array()) doc
  • array getAbuseReports(array $args = array()) doc
  • array getInterestGroupings(array $args = array()) doc
  • array getListActivity(array $args = array()) doc
  • array getListClients(array $args = array()) doc
  • array getListGrowthHistory(array $args = array()) doc
  • array getListMergeVars(array $args = array()) doc
  • array getLists(array $args = array()) doc
  • array getListLocations(array $args = array()) doc
  • array getListMembers(array $args = array()) doc
  • array getListMembersActivity(array $args = array()) doc
  • array getListMembersInfo(array $args = array()) doc
  • array getListSegments(array $args = array()) doc
  • array getListStaticSegments(array $args = array()) doc
  • array getListWebhooks(array $args = array()) doc
  • array resetListMergeVar(array $args = array()) doc
  • array resetStaticSegment(array $args = array()) doc
  • array setListMergeVar(array $args = array()) doc
  • array subscribe(array $args = array()) doc
  • array testListSegment(array $args = array()) doc
  • array unsubscribe(array $args = array()) doc
  • array updateInterestGroup(array $args = array()) doc
  • array updateInterestGrouping(array $args = array()) doc
  • array updateListMember(array $args = array()) doc
  • array updateListSegment(array $args = array()) doc

ECOMM RELATED METHODS:, (*20)

  • array addOrder(array $args = array()) doc
  • array deleteOrder(array $args = array()) doc
  • array getOrders(array $args = array()) doc

FOLDER RELATED METHODS:, (*21)

  • array addFolder(array $args = array()) doc
  • array deleteFolder(array $args = array()) doc
  • array getFolders(array $args = array()) doc
  • array updateFolders(array $args = array()) doc

TEMPLATE RELATED METHODS:, (*22)

  • array addTemplate(array $args = array()) doc
  • array deleteTemplate(array $args = array()) doc
  • array getTemplateInfo(array $args = array()) doc
  • array getTemplates(array $args = array()) doc
  • array undeleteTemplate(array $args = array()) doc
  • array updateTemplate(array $args = array()) doc

REPORT RELATED METHODS:, (*23)

  • array getCampaignAbuseReport(array $args = array()) doc
  • array getCampaignAdviceReport(array $args = array()) doc
  • array getCampaignBounceMessage(array $args = array()) doc
  • array getCampaignBounceMessages(array $args = array()) doc
  • array getCampaignSummaryReport(array $args = array()) doc
  • array getCampaignGoogleAnalyticsReport(array $args = array()) doc

USERS RELATED METHODS:, (*24)

  • array inviteUser(array $args = array()) doc
  • array getInvitations(array $args = array()) doc
  • array getLogins(array $args = array()) doc
  • array getProfile(array $args = array()) doc
  • array reinviteUser(array $args = array()) doc
  • array revokeLogin(array $args = array()) doc
  • array revokeUserInvitation(array $args = array()) doc

VIP RELATED METHODS:, (*25)

  • array addVipMembers(array $args = array()) doc
  • array deleteVipMembers(array $args = array()) doc
  • array getVipMembers(array $args = array()) doc
  • array getVipActivity(array $args = array()) doc

GALLERY RELATED METHODS:, (*26)

  • array getGalleryImages(array $args = array()) doc

HELPER RELATED METHODS:, (*27)

  • array getAccountDetails(array $args = array()) doc
  • array ping(array $args = array()) doc

Advanced usage

Attaching Guzzle plugins

UPDATE: Async plugin Guzzle 3 has been known to be very strange, and often not work as expected. Actually, it has even been removed in Guzzle 5. I'd suggest you to trying manually the Async plugin, but I recommend you NOT to use it., (*28)

Because ZfrMailChimp is built on top of Guzzle, you can take advantage of all the nice features of it. For instance, let's say you want to send requests asynchronously, you can simply attach the built-in Async plugin:, (*29)

use ZfrMailChimp\Client\MailChimpClient;
use Guzzle\Plugin\Async\AsyncPlugin;

$client = new MailChimpClient('my-secret-key');
$client->addSubscriber(new AsyncPlugin());
$response = $client->get()->send();

The Versions

24/11 2016

dev-master

9999999-dev https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

24/11 2016

v2.0.7

2.0.7.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

27/08 2015

v2.0.6

2.0.6.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

02/07 2014

dev-revert-20-guzzle-4

dev-revert-20-guzzle-4 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

26/06 2014

v2.0.5

2.0.5.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

07/06 2014

v2.0.4

2.0.4.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

16/04 2014

v2.0.3

2.0.3.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

17/03 2014

v2.0.2

2.0.2.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

02/02 2014

v2.0.1

2.0.1.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

27/12 2013

v2.0.0

2.0.0.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

mail mailchimp campaign

20/10 2013

v1.2.0

1.2.0.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

mail mailchimp campaign

10/10 2013

v1.1.1

1.1.1.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

mail mailchimp campaign

09/08 2013

v1.1.0

1.1.0.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

mail mailchimp campaign

30/07 2013

v1.0.0

1.0.0.0 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

mail mailchimp campaign

23/07 2013

v1.0.0-beta2

1.0.0.0-beta2 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

mail mailchimp campaign

17/07 2013

v1.0.0-beta1

1.0.0.0-beta1 https://github.com/zf-fr/zfr-mailchimp

PHP library for interacting with the v2 MailChimp REST API

  Sources   Download

MIT

The Requires

 

mail mailchimp campaign