zfr/zfr-mailchimp
Composer 安装命令:
composer require zfr/zfr-mailchimp
包简介
PHP library for interacting with the v2 MailChimp REST API
关键字:
README 文档
README
IMPORTANT: MailChimp has announced the removal of old API (including v1 and v2) in their blog post. Because this library is based on v2, it will stop working at the end of the year. I don't have the time to update this library to the v3 as today, but if anyone would like to tackle it... do not hesitate!
Note : this library does not contain tests, mainly because I'm not sure about how to write tests for an API wrapper. Don't hesitate to help on this ;-).
Introduction
This is an unofficial MailChimp PHP client for interacting with the v2 REST MailChimp API. If you are looking for a wrapper around previous MailChimp API versions (like 1.3), please refer to something else.
What is done
The following methods are supported by the client (not everything has been carefully tested though):
- Campaign related methods (complete)
- Ecomm related methods (complete)
- Vip related methods (complete)
- Folder related methods (complete)
- Users related methods (complete)
- Report related methods (only main methods)
- Templates related methods (complete)
- List related methods (nearly complete)
- Gallery related methods (complete)
- Helper related methods (partially complete)
Dependencies
- Guzzle library: >= 3.5
Integration with frameworks
To make this library even more easier to use, here are various frameworks integrations:
- ZfrMailChimpModule: a Zend Framework 2 module
- ZfrMailChimpBundle: a Symfony 2 bundle
Want to do an integration for another framework? Open an issue, and I'll open a repository for you!
Installation
We recommend you to use Composer to install ZfrMailChimp:
php composer.phar require zfr/zfr-mailchimp:2.*
Tutorial
Firstly, you need to instantiate the MailChimp client:
$client = new MailChimpClient('my-api-key');
The correct endpoint will be automatically chosen based on your API key.
You can then have access to all the methods available (see the list below):
// Get activity about a list $activity = $client->getListActivity(array( 'id' => 'list-id' )); // Add a new folder $client->addFolder(array( 'name' => 'my-folder-name', 'type' => 'template' ));
How to use it ?
You will notice that the method names below does not always have a 1-to-1 mapping with the API names. For instance, most methods that imply retrieving something are prefixed by "get".
However, there is an exact mapping for parameters. Therefore, you just need to refer to the official documentation for a given method (links are given below). Here is an example with the subscribe method:
$client->subscribe(array( 'id' => 'list-id', 'email' => array( 'email' => 'example@foo.com', 'euid' => '1545d' ) ));
Exceptions handling
ZfrMailChimp tries its best to extract meaningful exceptions from MailChimp errors. All exceptions implement the
ZfrMailChimp\Exception\ExceptionInterface interface, so you can use this to do a catch all block. You can find an
exhaustive list of all exceptions in the ZfrMailChimp\Exception folder.
List exceptions are under the Ls namespace, because list is a reserved keyword in PHP.
Usage example:
try { $client->subscribe(array( 'id' => 'list-id', 'email' => array( 'email' => 'example@foo.com', 'euid' => '1545d' ) )); } catch (\ZfrMailChimp\Exception\Ls\AlreadySubscribedException $e) { $message = $e->getMessage(); // You can do something interesting here! } catch(\ZfrMailChimp\Exception\Ls\DoesNotExistException $e) { // Do something else useful! } catch (\ZfrMailChimp\Exception\ExceptionInterface $e) { // Any other exception that may occur }
Complete reference
Here are the supported methods today:
CAMPAIGN RELATED METHODS:
- array createCampaign(array $args = array()) doc
- array deleteCampaign(array $args = array()) doc
- array getCampaignContent(array $args = array()) doc
- array getCampaigns(array $args = array()) doc
- array getTemplateContent(array $args = array()) doc
- array pauseCampaign(array $args = array()) doc
- array replicateCampaign(array $args = array()) doc
- array resumeCampaign(array $args = array()) doc
- array scheduleCampaign(array $args = array()) doc
- array scheduleBatchCampaign(array $args = array()) doc
- array sendCampaign(array $args = array()) doc
- array sendTestCampaign(array $args = array()) doc
- array testSegmentation(array $args = array()) doc
- array unscheduleCampaign(array $args = array()) doc
- array updateCampaign(array $args = array()) doc
LIST RELATED METHODS:
- array addInterestGroup(array $args = array()) doc
- array addInterestGrouping(array $args = array()) doc
- array addListMergeVar(array $args = array()) doc
- array addListSegment(array $args = array()) doc
- array addListWebhook(array $args = array()) doc
- array addStaticListSegment(array $args = array()) doc
- array addStaticSegmentMembers(array $args = array()) doc
- array batchSubscribe(array $args = array()) doc
- array batchUnsubscribe(array $args = array()) doc
- array deleteInterestGroup(array $args = array()) doc
- array deleteInterestGrouping(array $args = array()) doc
- array deleteListMergeVar(array $args = array()) doc
- array deleteListSegment(array $args = array()) doc
- array deleteListWebhook(array $args = array()) doc
- array deleteStaticSegmentMembers(array $args = array()) doc
- array getAbuseReports(array $args = array()) doc
- array getInterestGroupings(array $args = array()) doc
- array getListActivity(array $args = array()) doc
- array getListClients(array $args = array()) doc
- array getListGrowthHistory(array $args = array()) doc
- array getListMergeVars(array $args = array()) doc
- array getLists(array $args = array()) doc
- array getListLocations(array $args = array()) doc
- array getListMembers(array $args = array()) doc
- array getListMembersActivity(array $args = array()) doc
- array getListMembersInfo(array $args = array()) doc
- array getListSegments(array $args = array()) doc
- array getListStaticSegments(array $args = array()) doc
- array getListWebhooks(array $args = array()) doc
- array resetListMergeVar(array $args = array()) doc
- array resetStaticSegment(array $args = array()) doc
- array setListMergeVar(array $args = array()) doc
- array subscribe(array $args = array()) doc
- array testListSegment(array $args = array()) doc
- array unsubscribe(array $args = array()) doc
- array updateInterestGroup(array $args = array()) doc
- array updateInterestGrouping(array $args = array()) doc
- array updateListMember(array $args = array()) doc
- array updateListSegment(array $args = array()) doc
ECOMM RELATED METHODS:
- array addOrder(array $args = array()) doc
- array deleteOrder(array $args = array()) doc
- array getOrders(array $args = array()) doc
FOLDER RELATED METHODS:
- array addFolder(array $args = array()) doc
- array deleteFolder(array $args = array()) doc
- array getFolders(array $args = array()) doc
- array updateFolders(array $args = array()) doc
TEMPLATE RELATED METHODS:
- array addTemplate(array $args = array()) doc
- array deleteTemplate(array $args = array()) doc
- array getTemplateInfo(array $args = array()) doc
- array getTemplates(array $args = array()) doc
- array undeleteTemplate(array $args = array()) doc
- array updateTemplate(array $args = array()) doc
REPORT RELATED METHODS:
- array getCampaignAbuseReport(array $args = array()) doc
- array getCampaignAdviceReport(array $args = array()) doc
- array getCampaignBounceMessage(array $args = array()) doc
- array getCampaignBounceMessages(array $args = array()) doc
- array getCampaignSummaryReport(array $args = array()) doc
- array getCampaignGoogleAnalyticsReport(array $args = array()) doc
USERS RELATED METHODS:
- array inviteUser(array $args = array()) doc
- array getInvitations(array $args = array()) doc
- array getLogins(array $args = array()) doc
- array getProfile(array $args = array()) doc
- array reinviteUser(array $args = array()) doc
- array revokeLogin(array $args = array()) doc
- array revokeUserInvitation(array $args = array()) doc
VIP RELATED METHODS:
- array addVipMembers(array $args = array()) doc
- array deleteVipMembers(array $args = array()) doc
- array getVipMembers(array $args = array()) doc
- array getVipActivity(array $args = array()) doc
GALLERY RELATED METHODS:
- array getGalleryImages(array $args = array()) doc
HELPER RELATED METHODS:
Advanced usage
Attaching Guzzle plugins
UPDATE: Async plugin Guzzle 3 has been known to be very strange, and often not work as expected. Actually, it has even been removed in Guzzle 5. I'd suggest you to trying manually the Async plugin, but I recommend you NOT to use it.
Because ZfrMailChimp is built on top of Guzzle, you can take advantage of all the nice features of it. For instance, let's say you want to send requests asynchronously, you can simply attach the built-in Async plugin:
use ZfrMailChimp\Client\MailChimpClient; use Guzzle\Plugin\Async\AsyncPlugin; $client = new MailChimpClient('my-secret-key'); $client->addSubscriber(new AsyncPlugin()); $response = $client->get()->send();
zfr/zfr-mailchimp 适用场景与选型建议
zfr/zfr-mailchimp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 803.81k 次下载、GitHub Stars 达 43, 最近一次更新时间为 2013 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「mailchimp」 「campaign」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zfr/zfr-mailchimp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zfr/zfr-mailchimp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zfr/zfr-mailchimp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle for integrating the ZfrMailChimp library
Zend Framework 2 module for interacting with the v2 MailChimp API, built on top of ZfrMailChimp
A simple mechanism for implementing tracked interactive elements
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
MailChimp OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Create short URLs via Bit.ly, tagged with Google Analytics Campaign data.
统计信息
- 总下载量: 803.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 14
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-07-08