PHP code example of mlpz / mailchimp-bundle
1. Go to this page and download the library: Download mlpz/mailchimp-bundle library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mlpz / mailchimp-bundle example snippets bash
$ php composer.phar update mlpz/mailchimp-bundle
php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new MZ\MailChimpBundle\MZMailChimpBundle(),
);
}
php
$mailChimp = $this->get('MailChimp');
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
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
php
$mailChimp = $this->get('MailChimp');
$list = $mailChimp->getList();
$list->setEmail($oldEmail);
$list->MergeVars($newEmail);
/**
* Update user in mailing list
**/
$list->UpdateMember(); //boolean
php
$mailChimp = $this->get('MailChimp');
$list = $mailChimp->getList();
$list->listInterestGroupingAdd(
$groupTitle, $groupType,
array($group1, $group2)
); // integer grouping ID
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
php
$emails = array('email1','email2');
$mailChimp = $this->get('MailChimp');
$campaign = $mailChimp->getCampaign();
$campaign->SendTest($campaignId, $emails); // return boolean
php
$mailChimp = $this->get('MailChimp');
$campaign = $mailChimp->getCampaign();
$campaign->SendNow($campaignId); // return boolean
php
$mailChimp = $this->get('MailChimp');
$export = $mailChimp->getExport();
$options = array('status' => 'unsubscribed'); //subscribed, unsubscribed, cleaned
$export->DumpList($options); //return array
php
$mailChimp = $this->get('MailChimp');
$list = $mailChimp->getList();
$list->getMemberInfo($email)
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
php
$mailChimp = $this->get('MailChimp');
$ecommerce = $mailChimp->getEcommerce();
$ecommerce->deleteOrder($storeId, $orderId) //return boolean
php
$mailChimp = $this->get('MailChimp');
$ecommerce = $mailChimp->getEcommerce();
$ecommerce->getOrder($pageStart, $batchLimit, $dateSince) //return array
php
$mailChimp = $this->get('MailChimp');
$list = $mailChimp->getList();
$list->listStaticSegmentAdd('first_segment'); // return int segment id
php
$mailChimp = $this->get('MailChimp');
$list = $mailChimp->getList();
$segmentId = $list->listStaticSegmentAdd('first_segment');
$batch = array('[email protected] ', '[email protected] ');
$list->listStaticSegmentMembersAdd($segmentId, $batch);
php
$mailChimp = $this->get('MailChimp');
$list = $mailChimp->getList();
$segments = $list->listStaticSegments();
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);
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();
php
$mailChimp = $this->get('MailChimp');
$campaign = $mailChimp->getCampaign();
$campaign->campaignStats($campaignId); //return array(), struct of the statistics for this campaign