定制 chimpmatic/mailchimp-api-key-validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chimpmatic/mailchimp-api-key-validator

Composer 安装命令:

composer require chimpmatic/mailchimp-api-key-validator

包简介

Validate Mailchimp API key format, detect common errors (whitespace, missing datacenter suffix), and verify connectivity.

README 文档

README

Latest Version PHP Version License

Validate Mailchimp API key format, detect common errors, and optionally verify connectivity — all without hitting the Mailchimp API until you're ready.

Author: Chimpmatic

Why This Exists

The most common support request for any Mailchimp integration is "Invalid API Key." The causes are always the same:

  • Extra whitespace when pasting
  • Missing datacenter suffix (-us4)
  • Truncated key (copied only part of it)
  • Revoked or disabled key

This library catches all of these before making an API call, giving your users clear error messages instead of a generic failure.

Need to get your Mailchimp API key first? See How to Get Your Mailchimp API Key for a one-click shortcut.

Installation

composer require chimpmatic/mailchimp-api-key-validator

Quick Start

use Chimpmatic\MailchimpKeyValidator\ApiKeyValidator;

$validator = new ApiKeyValidator();

// Format validation (no network call)
$result = $validator->validate('aaaaaaaaaabbbbbbbbbbccccccccccdd-us4');

if ($result->isValid()) {
    echo $result->getDatacenter(); // "us4"
    echo $result->getHash();       // "aaaaaaaaaabbbbbbbbbbccccccccccdd"
} else {
    foreach ($result->getErrors() as $error) {
        echo $error;
    }
}

Connectivity Verification

Optionally verify the key works against the Mailchimp API (requires curl):

$result = $validator->verifyConnectivity('aaaaaaaaaabbbbbbbbbbccccccccccdd-us4');

if ($result->isValid()) {
    echo 'Connected to Mailchimp!';
    echo $result->getHttpStatus(); // 200
}

What It Catches

Issue Detection Message
Empty key Format check API key is empty.
Leading/trailing whitespace Format check Warning + auto-trim
Internal whitespace Format check Key contains whitespace characters.
Missing -us4 suffix Format check Missing datacenter suffix.
Wrong hash length Format check Key hash is N characters, expected 32.
Non-hex characters Format check Key hash contains non-hexadecimal characters.
Invalid datacenter format Format check Datacenter "X" does not match expected format.
Unknown datacenter Format check Warning (may be newer DC)
Revoked/disabled key Connectivity check API key is rejected by Mailchimp.
Insufficient permissions Connectivity check API key lacks sufficient permissions.

ValidationResult API

$result->isValid();         // bool — true if no errors
$result->getErrors();       // string[] — list of error messages
$result->getWarnings();     // string[] — list of warning messages
$result->hasWarnings();     // bool — true if warnings exist
$result->getSanitizedKey(); // string — trimmed key
$result->getHash();         // ?string — 32-char hex hash or null
$result->getDatacenter();   // ?string — datacenter ID or null
$result->getHttpStatus();   // ?int — HTTP status from connectivity check
$result->getSummary();      // string — human-readable summary

Requirements

  • PHP 7.4 or higher
  • curl extension (only for verifyConnectivity())

Testing

composer test

Or run PHPUnit directly:

vendor/bin/phpunit

Links

License

MIT License. Copyright (c) 2026 Chimpmatic.

chimpmatic/mailchimp-api-key-validator 适用场景与选型建议

chimpmatic/mailchimp-api-key-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mailchimp」 「validator」 「wordpress」 「api-key」 「contact-form-7」 「mailchimp-api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 chimpmatic/mailchimp-api-key-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 chimpmatic/mailchimp-api-key-validator 我们能提供哪些服务?
定制开发 / 二次开发

基于 chimpmatic/mailchimp-api-key-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 36
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-17