hampel/mailchimp-subscribe
Composer 安装命令:
composer require hampel/mailchimp-subscribe
包简介
Wrapper for the list subscription and management methods of the MailChimp API v3 using Guzzle
关键字:
README 文档
README
A MailChimp API wrapper using Guzzle v6 which implements a simple list subscription interface using the MailChimp v3 API.
By Simon Hampel.
Installation
The recommended way of installing MailChimp Subscribe is through Composer:
:::json
{
"require": {
"hampel/mailchimp-subscribe": "~1.0"
}
}
Configuration
To use the MailChimp subscriber, you'll need to generate an API key using the MailChimp admin interface.
Log in to MailChimp and then go to Account by clicking on your username/avatar at the top and selecting Account from
the menu.
Next, go to the Extras area and click on API Keys.
Click on the Create a Key button and give your new key a meaningful label so you know which one it is.
You'll also need to find the list ID of the mailing list you want to subscribe people to.
Click on Lists at the top and then click on your list name.
Click on the Settings submenu and select the List name and campaign defaults option.
Over on the right will be your List ID - make a note of this.
Usage
Initialisation
To start with, you'll need to create a MailChimp object which does the actual communication.
The quick way is to use the factory:
:::php
<?php
use MailChimp\MailChimp;
$apikey = 'YOUR API KEY HERE';
$mc = MailChimp::make($apikey);
Alternatively, if you need more control, you can use the long-hand method:
:::php
<?php
use GuzzleHttp\Client;
use MailChimp\MailChimp;
$apikey = 'YOU API KEY HERE';
$config = MailChimp::getConfig($apikey);
$guzzle = new Client($config);
$mc = new MailChimp($guzzle, $apikey);
You'll also want to create a mailing list object to then work with the list:
:::php
<?php
use MailChimp\MailingList;
$listid = 'YOU LIST ID HERE';
$list = new MailingList($mc, $listid);
We're now ready to work with our list.
Get Member
You can retrieve the details of a member by calling the getMember method of the MailingList class:
:::php
<?php
var_dump($list->getMember('user@example.com'));
The getMember function returns false if the email address was not found in the list.
Get Member Status
Retrieve the current status of a list member by calling the getMemberStatus method:
:::php
<?php
var_dump($list->getMemberStatus('user@example.com'));
Possible return values are: subscribed, unsubscribed, cleaned, pending - or false if the member was not found.
Check if Member Exists
You can check if a user is a member of a list with the isMember method, which returns a boolean result:
:::php
<?php
if ($list->isMember('user@example.com'))
{
echo "user is a member of our list";
}
else
{
echo "user is not yet a member of our list";
}
Subscribe a Member
Subscribe a new email address to your list using the subscribe method:
:::php
<?php
var_dump($list->subscribe('user@example.com'));
To have MailChimp send a confirmation to the user before adding them to your list (double opt-in), set the second
parameter to true: $list->subscribe('user@example.com', true)
You may also send an associative array of merge fields (name-value pairs) as a third parameter:
:::php
<?php
var_dump($list->subscribe('user@example.com', false, ['FNAME' => 'Joe', 'LNAME' => 'Bloggs']));
Details about the subscribed user will be returned.
Unsubscribe a Member
To remove a user from the mailing list, use the unsubscribe method:
:::php
<?php
var_dump($list->unsubscribe('user@example.com'));
Clean a Member
To clean an address from the mailing list, use the clean method:
:::php
<?php
var_dump($list->clean('user@example.com'));
Cleaned addresses are addresses that have bounced too many times or are now considered invalid.
hampel/mailchimp-subscribe 适用场景与选型建议
hampel/mailchimp-subscribe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mailchimp」 「api」 「Guzzle」 「subscribe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hampel/mailchimp-subscribe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hampel/mailchimp-subscribe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hampel/mailchimp-subscribe 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
MailChimp OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Manage newsletters in Laravel
The Automated Provision of Email Services (APES) module will allow you to set up an automated sync mechanism between the SilverStripe Member DataObject and MailChimp.
Cloudflare Middleware For Guzzle
Simplifies working with holaluz API endpoints
统计信息
- 总下载量: 47
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-17