GithubHelp home page GithubHelp logo

mzmailchimpbundle's Introduction

MZMailChimpBundle

Symfony2 bundle for MailChimp API And Export API

Build Status Total Downloads Latest Stable Version

License

MZMailChimpBundle is licensed under the MIT License - see the Resources/meta/LICENSE file for details

MailChimp API Method Supported

  1. listSubscribe
  2. listUnSubscribe
  3. listUpdateMember
  4. listInterestGroupingAdd
  5. campaignCreate
  6. campaignSendTest
  7. campaignSendNow
  8. listStaticSegmentAdd
  9. listStaticSegmentMembersAdd
  10. listStaticSegments
  11. campaigns
  12. campaignStats

MailChimp Export API Method Supported

1. list

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

Setup

Step 1: Download MZMailChimpBundle using composer

Add MZMailChimpBundle in your composer.json:

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

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

$ php composer.phar update mlpz/mailchimp-bundle

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

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new MZ\MailChimpBundle\MZMailChimpBundle(),
    );
}

Step 3: Add configuration

# app/config/config.yml
mz_mail_chimp:
  api_key: #Mailchimp API Key
  default_list: #default list id
  ssl: true #option to use http or https

Usage

Using service

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

MailChimp API Subscribe user to mailing list in a controller

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

        /**
         * Change mailing list
         * */
        $mailChimp->setListID($id);

        /**
         * Get list methods
         * */
        $list = $mailChimp->getList();

        /**
         * listSubscribe default Parameters
         * */
        $list->setMerge($array);  //optional default: null
        $list->setEmailType('html'); //optional default: html
        $list->setDoubleOptin(true);  //optional default : true
        $list->setUpdateExisting(false); // optional default : false
        $list->setReplaceInterests(true);  // optional default : true
        $list->SendWelcome(false);  // optional default : false

        /**
         * Subscribe user to list
         * */
        $list->Subscribe($email); //boolean

MailChimp API Unsubscribe remove user from mailing list in a controller

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

        /**
         * Change mailing list
         * */
        $mailChimp->setListID($id);

        /**
         * Get list methods
         * */
        $list = $mailChimp->getList();

        /**
         * UnSubscribe user from list
         * */
        $list->UnSubscribe($email); //boolean

MailChimp API Update user in a controller

<?php
        $mailChimp = $this->get('MailChimp');
        $list = $mailChimp->getList();
        $list->setEmail($oldEmail);
        $list->MergeVars($newEmail);

        /**
        * Update user in mailing list
        **/
        $list->UpdateMember(); //boolean

MailChimp API Interest Grouping Add in a controller

<?php
        $mailChimp = $this->get('MailChimp');
        $list = $mailChimp->getList();
        $list->listInterestGroupingAdd(
            $groupTitle, $groupType,
            array($group1, $group2)  
        ); // integer grouping ID
                   

MailChimp API create campaign in a controller

<?php
        $mailChimp = $this->get('MailChimp');
        $campaign = $mailChimp->getCampaign();
        $campaign->setType($type);
        $campaign->setSubject($subject);
        $campaign->setFromEmail($fromEmail);
        $campaign->setFromName($fromName);
        $campaign->setHTML($html);


        $campaign->create(); //return campaign id

MailChimp API send test campaign in a controller

<?php

        $emails = array('email1','email2');
        $mailChimp = $this->get('MailChimp');
        $campaign = $mailChimp->getCampaign();
        $campaign->SendTest($campaignId, $emails); // return boolean

MailChimp API send campaign in a controller

<?php
        
        $mailChimp = $this->get('MailChimp');
        $campaign = $mailChimp->getCampaign();
        $campaign->SendNow($campaignId); // return boolean

MailChimp Export API List in controller

<?php
       $mailChimp = $this->get('MailChimp');
       $export = $mailChimp->getExport();
       $options = array('status' => 'unsubscribed'); //subscribed, unsubscribed, cleaned
       $export->DumpList($options); //return array

MailChimp API Listmemberinfo in controller

<?php
       $mailChimp = $this->get('MailChimp');
       $list = $mailChimp->getList();
       $list->getMemberInfo($email) 

MailChimp API Import Ecommerce Order in controller

<?php
       $mailChimp = $this->get('MailChimp');
       $ecommerce = $mailChimp->getEcommerce();

       $ecommerce->setOrderId($orderId)
       $ecommerce->setOrderDate($orderDate)
       $ecommerce->setStoreId($storeId)
       $ecommerce->setStoreName($storeName)
       $ecommerce->setCampaignId($mailChimpCampaigId)
       $ecommerce->setShipping($shippingTotal)
       $ecommerce->setTax($taxTotal)
       $ecommerce->setTotal($orderTotal)
       $ecommerce->addItem($productId, $productName, $categoryId, $categoryName, $qty, $cost, $sku)
       
       $ecommerce->addOrder($email) //return boolean

MailChimp API Delete Ecommerce Order in controller

<?php
       $mailChimp = $this->get('MailChimp');
       $ecommerce = $mailChimp->getEcommerce();
       
       $ecommerce->deleteOrder($storeId, $orderId) //return boolean

MailChimp API Retrieve Ecommerce Orders in controller

<?php
       $mailChimp = $this->get('MailChimp');
       $ecommerce = $mailChimp->getEcommerce();
       
       $ecommerce->getOrder($pageStart, $batchLimit, $dateSince) //return array

MailChimp API create static segment in a controller

<?php

        $mailChimp = $this->get('MailChimp');
	$list = $mailChimp->getList();
        $list->listStaticSegmentAdd('first_segment'); // return int segment id

MailChimp API segment member add in a controller

<?php

        $mailChimp = $this->get('MailChimp');
	$list = $mailChimp->getList();
        $segmentId = $list->listStaticSegmentAdd('first_segment');
	$batch = array('[email protected]', '[email protected]');
	$list->listStaticSegmentMembersAdd($segmentId, $batch);	

MailChimp API list static segment in a controller

<?php

        $mailChimp = $this->get('MailChimp');
	$list = $mailChimp->getList();
        $segments = $list->listStaticSegments();

MailChimp API [send campaign to segment] in a controller

<?php

        $mailChimp = $this->get('MailChimp');
	$campaign = $mailChimp->getCampaign();
	$list = $mailChimp->getList();
        $segmentId = $list->listStaticSegmentAdd('first_segment');
	$batch = array('[email protected]', '[email protected]');
	$list->listStaticSegmentMembersAdd($segmentId, $batch);	
	$conditions[] = array(
				'field' => 'static_segment',
				'op'    => 'eq',
				'value' => $segmentId
		);

	$segment_options = array(
				'match'      => 'all',
				'conditions' => $conditions
		);
	$campaign->setSegmenOptions($segment_options);
	$campaignId =  $campaign->create();
	$campaign->SendNow($campaignId);

MailChimp API campaigns in a controller

<?php

        $mailChimp = $this->get('MailChimp');
	$campaign = $mailChimp->getCampaign();
	//get all campaigns
	$campaign->campaigns();
<?php

        $mailChimp = $this->get('MailChimp');
	$campaign = $mailChimp->getCampaign();
	//filters for example campaign_id, you can all the filters in api website
	$campaign->setFilters(array('campaign_id' => 4589));
	$campaign->campaigns();

MailChimp API campaignStats in a controller

<?php

        $mailChimp = $this->get('MailChimp');
	$campaign = $mailChimp->getCampaign();
        $campaign->campaignStats($campaignId); //return array(),  struct of the statistics for this campaign

mzmailchimpbundle's People

Contributors

miguel250 avatar ollietb avatar webkmua avatar jsavolainen avatar toooni avatar phobetor avatar nyholm avatar soerenmartius avatar jorns avatar titouan13 avatar dlondero avatar maks-rafalko avatar oskarstark avatar brunonic avatar marlonbaeten avatar

Watchers

Ruben Nijveld avatar James Cloos avatar  avatar Erik Jonkers avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.