amrelhagary / HypeMailchimpBundle

Symfony2 Mailchimp API V2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hype MailchimpBundle for API V2.0

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

HypeMailChimp bundle 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

Export API

  1. list
  2. campaignSubscriberActivity

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

Setup

Step 1: Download HypeMailchimp using composer

Add HypeMailchimp in your composer.json:

{
    "require": {
        "ahmedsamy/hype-mailchimp-bundle": "dev-master"
    }
}

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

$ php composer.phar update "ahmedsamy/hype-mailchimp-bundle"

Composer will install the bundle to your project's vendor/ahmedsamy/hype directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

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

Step 3: Add configuration

# app/config/config.yml
hype_mailchimp:
    api_key: xxxxxxx-us5
    default_list: xxxxxxxx
    ssl: true #optional configuring curl connection

Usage

Using service

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

##Examples

###Create new campaign

<?php 
    $mc = $this->get('hype_mailchimp');
        $data = $mc->getCampaign()->create('regular', array(
            'list_id' => '93419bbdc0',
            'subject' => 'test created subject',
            'from_email' => 'ahmed.samy.cs@gmail.com',
            'from_name' => 'Ahmed Samy',
            'to_name' => 'fans'
                ), array(
            'html' => '<h5>Html content</h5>',
            'sections' => array(),
            'text' => 'test',
            'url' => 'http://www.example.com',
            'archive' => 'test'
        ));
        var_dump($data);
?>

###Delete existing campaign

<?php 
     $mc = $this->get('hype_mailchimp');
     $data = $mc->getCampaign()
                ->setCi('1088b4ed65')
                ->del();

        var_dump($data);
?>

###Send campaign

<?php 
     $mc = $this->get('hype_mailchimp');
     $data = $mc->getCampaign()
                ->setCi('1088b4ed65')
                ->send();

        var_dump($data);
?>

###Subscribe new user to list

<?php 
     $mc = $this->get('hype_mailchimp');
     $data = $mc->getList()
                ->addMerge_vars(
                        array(
                            'mc_notes' => 'test notes'
                ))
                ->subscribe('moneky@suitMonkry.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 
     $mc = $this->get('hype_mailchimp');
     $data = $mc->getList()
                ->setListId('xxxxxxx')
                ->addMerge_vars(
                        array(
                            'mc_notes' => 'test notes'
                ))
                ->subscribe('moneky@suitMonkry.com');
?>

About

Symfony2 Mailchimp API V2