testudio / mailchimp-marketing
3.0.72
2021-11-02 19:12 UTC
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.2
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.12
- phpunit/phpunit: ^7
- squizlabs/php_codesniffer: ~2.6
- dev-master
- 3.0.72
- 3.0.71
- 3.0.70
- 3.0.69
- 3.0.68
- 3.0.67
- 3.0.66
- 3.0.65
- 3.0.64
- 3.0.63
- 3.0.62
- 3.0.61
- 3.0.59
- 3.0.58
- 3.0.57
- 3.0.56
- 3.0.55
- 3.0.54
- 3.0.53
- 3.0.52
- 3.0.51
- 3.0.50
- 3.0.49
- 3.0.48
- 3.0.47
- 3.0.46
- 3.0.45
- 3.0.44
- 3.0.43
- 3.0.42
- 3.0.41
- 3.0.40
- 3.0.39
- 3.0.38
- 3.0.37
- 3.0.36
- 3.0.35
- 3.0.34
- 3.0.33
- 3.0.32
- 3.0.31
- 3.0.30
- 3.0.29
- 3.0.28
- 3.0.27
- 3.0.26
- 3.0.25
- 3.0.24
- 3.0.23
- 3.0.22
- dev-add-license
This package is auto-updated.
Last update: 2024-09-13 08:38:02 UTC
README
Mailchimp Marketing — PHP
此分支是基于官方 Mailchimp Marketing API 的 PHP 客户端库,使其与 Drupal 9 兼容,直到此 pull request 解决。
安装
选项 1: 通过 Packagist 安装
composer require testudio/mailchimp-marketing
或将以下内容添加到 composer.json
{
"require": {
"testudio/mailchimp-marketing": "*"
}
}
使用以下命令安装所有 composer 依赖项
composer install
选项 2: 手动安装
克隆存储库
git clone git@github.com:testudio/mailchimp-marketing-php.git
在客户端库项目根目录中,安装所有依赖项
composer install
手动将 vendor/autoload.php
包含到您的实现中
require_once('/path/to/MailchimpMarketing/vendor/autoload.php');
快速入门
请注意,此 SDK 需要 PHP 7.2 或更高版本。
require_once('/path/to/MailchimpMarketing/vendor/autoload.php'); $mailchimp = new MailchimpMarketing\ApiClient(); $mailchimp->setConfig([ 'apiKey' => 'YOUR_API_KEY', 'server' => 'YOUR_SERVER_PREFIX' ]); $response = $mailchimp->ping->get(); print_r($response);
身份验证方法
客户端库可以配置为使用 基本身份验证 或 OAuth2。
对于任何一种方法,都应传递一个服务器前缀,例如 us19
,以便客户端确定适当的 URL。
基本身份验证
$mailchimp->setConfig([ 'apiKey' => 'YOUR_API_KEY', 'server' => 'YOUR_SERVER_PREFIX' ]);
OAuth2
$mailchimp->setConfig([ 'accessToken' => 'YOUR_ACCESS_TOKEN', 'server' => 'YOUR_SERVER_PREFIX' ]);
PRs 和 Issues
此存储库是从 https://github.com/mailchimp/mailchimp-client-lib-codegen 自动生成的 - 请在此处提交 PR 或 issues!
其他配置选项
APIClient 类允许您设置各种配置选项,如超时、主机、用户代理和调试输出。有关更多详细信息,请参阅 https://github.com/mailchimp/mailchimp-marketing-php/blob/master/lib/Configuration.php。
API 端点
所有 URI 都相对于 https://server.api.mailchimp.com/3.0
示例
lists.createSegment
// Create tag (static).
$segment = $mailchimp->lists->createSegment($list_id, '{"name":"Tag 1","static_segment":[]}');
// Create segment (dynamic tag).
$segment = $mailchimp->lists->createSegment($list_id,
'{"name":"Segment 2","options":{"match":"any","conditions":[]}}');
lists.deleteSegment
$segment_id = $segment->id;
$segment_list_id = $segment->list_id;
$mailchimp->lists->deleteSegment($segment_list_id, $segment_id);
lists.getAllLists
$response = $mailchimp->lists->getAllLists();
foreach ($response->lists as $list) {
$list_id = $list->id;
$list_name = $list->name;
...
}
lists.getList
$list_id = '7f4f516be';
$list = $mailchimp->lists->getList($list_id);
if ($list) {
$list_id = $list->id;
$list_name = $list->name;
...
}
lists.getListInterestCategories
$response = $mailchimp->lists->getListInterestCategories($list_id);
foreach ($response->categories as $category) {
$category_id = $category->id;
$category_title = $category->title;
...
}
lists.listSegments
$list_id = '7f4f516be';
// Load up to 10 tags.
$response = $mailchimp->lists->listSegments($list_id);
// Load up to 200 tags.
$response = $mailchimp->lists->listSegments($list_id, NULL, NULL, '200');
if ($response) {
foreach ($response->segments as $segment) {
$segment_id = $segment->id;
$segment_name = $segment->name;
$segment_member_count = $segment->member_count;
$segment_list_id = $segment->list_id;
}
}
其他库
Mailchimp Marketing 库以下列语言可用



