reneeshkuttan/whitemail-api

此包为Whitemail Api提供包装器

1.0.0 2016-11-28 05:14 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:24:43 UTC


README

WhitemailApi 是一个用于 whitemail api 的 PHP 包装器。

内容

安装

  1. 为了安装 WhitemailApi,只需将以下内容添加到您的 composer.json 文件中。然后运行 composer update
"reneeshkuttan/whitemail-api": "1.0.x-dev"

使用

要求

在开始之前,从 whitemail 的公司设置页面获取您的 API 终端点 URL 和 API 密钥

初始化

让我们首先创建一个新的 WhitemailApi 实例

$api = new WhitemailApi($apiEndPoint, $apiKey);

识别

现在我们可以通过 API 发送一个调用以识别订阅者

$subscriberData = [
	'email'  => "johns@example.com",
            'fields' => [
                'first_name' => 'John',
                'last_name' => 'Sam'
             ]
];

$api->identify($subscriberData);

在成功请求后,identify 函数将返回一个包含订阅者详情的关联数组

Array ( [success] => 1 [message] => Subscriber succesfully created/updated [subscriber] => Array ( [id] => 31 [uris] => Array ( [show] => http://client1.whitemail5.dev/subscriber/31 ) ) ) 

跟踪

使用 track() 函数跟踪订阅者事件

$trackData = [
            'email' => 'johns@example.com',
            'eventName' => 'purchased',
            'data' => ['amt' => '40.50'],
        ];

$api->track($trackData);

成功时,这将返回一个包含状态信息的关联数组

Array ( [success] => 1 [message] => Subscriber event added ) 

许可证

WhitemailApi 是免费软件,根据 MIT 许可证条款发布。