mlpz/mailchimp-bundle

此包已废弃,不再维护。未建议替代包。

mailchimp bundle

安装数: 116,324

依赖项: 0

建议者: 0

安全性: 0

星级: 55

关注者: 9

分支: 29

开放问题: 13

类型:symfony-bundle

v1.3 2014-10-07 05:23 UTC

This package is not auto-updated.

Last update: 2020-01-18 09:44:30 UTC


README

Symfony2 用于 MailChimp API 和 Export API 的包

Build Status Total Downloads Latest Stable Version

许可证

MZMailChimpBundle 采用 MIT 许可证授权 - 有关详细信息,请参阅 Resources/meta/LICENSE 文件

支持的 MailChimp API 方法

  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 方法

1. list

如需支持列表中未列出的方法,请提交 问题

设置

步骤 1:使用 composer 下载 MZMailChimpBundle

在您的 composer.json 中添加 MZMailChimpBundle

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

现在,运行以下命令告诉 composer 下载包

$ php composer.phar update mlpz/mailchimp-bundle

Composer 将将包安装到您项目的 vendor/mlpz 目录。

步骤 2:启用包

在 kernel 中启用包

<?php
// app/AppKernel.php

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

步骤 3:添加配置

# 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

用法

使用服务

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

在控制器中使用 MailChimp API Subscribe 用户到邮件列表

<?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 从邮件列表中删除用户

<?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 用户

<?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

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

在控制器中使用 MailChimp API create campaign

<?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

<?php

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

在控制器中使用 MailChimp API send campaign

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

在控制器中使用 MailChimp Export API List

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

在控制器中使用 MailChimp API Listmemberinfo

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

在控制器中使用 MailChimp API Import Ecommerce Order

<?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

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

在控制器中使用 MailChimp API Retrieve Ecommerce Orders

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

在控制器中使用 MailChimp API create static segment

<?php

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

MailChimp API 在控制器中添加静态分段成员

<?php

        $mailChimp = $this->get('MailChimp');
	$list = $mailChimp->getList();
        $segmentId = $list->listStaticSegmentAdd('first_segment');
	$batch = array('test1@example.com', 'test2@example.com');
	$list->listStaticSegmentMembersAdd($segmentId, $batch);	

MailChimp API 在控制器中列出静态分段

<?php

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

MailChimp API 在控制器中[向分段发送活动]

<?php

        $mailChimp = $this->get('MailChimp');
	$campaign = $mailChimp->getCampaign();
	$list = $mailChimp->getList();
        $segmentId = $list->listStaticSegmentAdd('first_segment');
	$batch = array('test1@example.com', 'test2@example.com');
	$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 在控制器中活动

<?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 在控制器中活动统计

<?php

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