hugofirth/mailchimp

基于Mailchimp提供的Mailchimp类包装器 - 支持Laravel 4。v2.0.0支持Mailchimp API版本2.0

v2.0.3 2013-11-26 10:36 UTC

This package is not auto-updated.

Last update: 2024-09-28 13:09:41 UTC


README

该包支持与Laravel框架(v4)一起使用,提供了一个MailchimpWrapper外观。

###安装

为了安装,请在composer.json文件的require块中添加以下内容

"require": {
    
    "hugofirth/mailchimp": "2.0.*",
    
}

在Laravel中,找到文件..app/config/app.php *。

将以下内容添加到providers数组中

'providers' => array(
    …
    'Hugofirth\Mailchimp\MailchimpServiceProvider',
    …
),

此外,将以下内容添加到aliases数组中

'aliases' => array(
    …
    'MailchimpWrapper'       => 'Hugofirth\Mailchimp\Facades\MailchimpWrapper',
    …
),

发布配置

$ php artisan config:publish hugofirth/mailchimp

最后,运行命令composer update

* 下面的步骤应针对为任何额外环境创建的任何app.php文件重复。

###使用

您的独特MailChimp API密钥应在包的配置文件中设置,该文件位于app/config/packages/hugofirth/mailchimp/config.php

MailChimp API类的方法如MailChimp API文档所述,可在此处找到。实际使用的示例可在此处找到(警告:示例使用CakePHP)。感谢Laravel使用“外观”设计模式,所有方法都可以以下方式调用

…
//Retrieve an array of lists for your account
$lists = MailchimpWrapper::lists()->getList()['data'];
…
//Subscribe a user, with email: $email_address, to a list with id: $list_id
MailchimpWrapper::lists()->subscribe($list_id, array('email'=>$email_address));

为了允许自动完成,您可以包含外观的use语句

<?php

use Hugofirth\Mailchimp\Facades\MailchimpWrapper;

class SomeClass
{
    public function someMethod()
    {
        MailchimpWrapper:: //You should be able to get auto completion here for the API methods/properties
    }
}

享受吧!