prolixtechnikos/mailchimp-bundle

Mailchimp v2.0 API Wrapper

dev-master 2013-11-21 13:01 UTC

This package is auto-updated.

Last update: 2024-09-11 22:02:13 UTC


README

Symfony2.x bundle for MailChimp API V2 and Export API API V1 Wrapper bundle that makes accessing Mailchimp functions easily in object oriented using method chaining

License

ProlixMailChimpBundle released under MIT LICENSE

#Supported API Methods

Campaigns related

  1. campaigns/create
  2. campaigns/content
  3. campaigns/list
  4. campaigns/delete
  5. campaigns/pause
  6. campaigns/ready
  7. campaigns/replicate
  8. campaigns/ready
  9. campaigns/resume
  10. campaigns/send
  11. campaigns/send-test
  12. campaigns/segment-test
  13. campaigns/schedule
  14. campaigns/schedule-batch
  15. campaigns/unschedule
  16. campaigns/update

Lists related

  1. lists/abuse-reports
  2. lists/activity
  3. lists/subscribe
  4. lists/unsubscribe
  5. lists/member-info
  6. lists/interest-groupings
  7. lists/interest-grouping-add
  8. lists/interest-grouping-del
  9. lists/interest-grouping-update
  10. lists/interest-group-add
  11. lists/interest-group-update
  12. lists/interest-group-del

Templates related

  1. templates/add
  2. templates/list
  3. templates/del
  4. templates/info
  5. templates/undel

Need support for a method not on the list submit an issue

Setup

Step 1: Download ProlixMailchimp using composer

Add ProlixMailchimp in your composer.json:

{
    "require": {
        "prolixtechnikos/mailchimp-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update "prolixtechnikos/mailchimp-bundle"

Composer will install the bundle to your project's vendor/prolixtechnikos/mailchimp-bundle directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Prolix\MailchimpBundle\ProlixMailchimpBundle(),
    );
}

Step 3: Add configuration

# app/config/config.yml
prolix_mailchimp:
    api_key: xxxxxxx-us5
    default_list: xxxxxxxx
    ssl: true #optional configuring curl connection
    # this will hold the curl options. Just use the php curl option constant as key and value
    curl_options:  
      curlopt_useragent: ProlixMailChimp
      curlopt_timeout: 30 

Usage

Using service

<?php
        $mailchimp = $this->get('mailchimp');
?>

##Examples

###Create new campaign

<?php 
    $campaignApi = $this->get('mailchimp.campaign');
    $data = $campaignApi->create('regular', 
    array(
        'list_id' => 'xxxxxxxx',
        'from_name' => 'Ravindra Khokharia',
        'from_email' => 'ravindrakhokharia@gmail.com',
        'subject' => 'Subscribe to Prolix NewsLetter',
        'to_name' => 'ProlixTechnikos Subscriber'),
    array(
        'archive' => 'test'
        'sections' => array(),
        'text' => 'test',
        'html' => '<b>Test HTML Data</b>',
        'url' => 'http://www.prolixtechnikos.com',
    ));

    var_dump($data);
?>

###Delete existing campaign

<?php 
    $campaignApi = $this->get('mailchimp.campaign');
    $data = $campaignApi->setCampaignId('xxxxxxxx')->delete();

    var_dump($data);
?>

###Send campaign

<?php 
    $campaignApi = $this->get('mailchimp.campaign');
    $data = $campaignApi->setCampaignId('xxxxxxxx')->send();

    var_dump($data);
?>

###Subscribe new user to list

<?php 
    $listApi = $this->get('mailchimp.list');
    $data = $listApi->subscribe('subscriber@prolixtechnikos.com');
    
    var_dump($data);
?>

Note that the user will be subscriber to the default list set in config.yml if you want to change the list for this time only, you can use

<?php 
    $listApi = $this->get('mailchimp.list');
    $data = $listApi->setListId('xxxxxxx')
        ->subscribe('subscriber@prolixtechnikos.com');

    var_dump($data);
?>