barnebys / mautic-api-helper
此软件包已被废弃,不再维护。未建议替代软件包。
V0.4.0
2018-03-15 15:50 UTC
Requires
- php: >=5.5
- ext-curl: *
- mautic/api-library: 2.10.0
- psr/log: ~1.0
README
Mautic API Helper
需要安装 Mautic Simple Mail 插件。
基本认证
BarnebysMautic\Auth::initializeHttpBasic('username', 'password');
BarnebysMautic\Api::setBaseUrl('https://my.mautic.domain/api');
OAuth 认证
BarnebysMautic\Auth::initializeOAuth2
通过电子邮件获取联系人 ID
try {
$data = BarnebysMautic\Api::getContactIdByMail('some@email.com');
} catch (BarnebysMautic\Exception\ContactNotFoundException $exception) {
// Handle error
}
处理联系人
创建联系人
BarnebysMautic\Api::createContact($email, array $fields = [);
更新联系人
更新联系人将执行 PATCH 操作,并只更新数组中指定的字段。
BarnebysMautic\Api::updateContact($email, array $fields = [);
发送电子邮件
在发送电子邮件时,您可以使用 sendToContact 并仅设置电子邮件和模板 ID。如果您需要将一些自定义字段传递到 Mautic 中使用,可以将它们作为键 => 值数组设置为第三个参数。当发送值包含 HTML 时,要禁用 Mautic HTML 转义器,请将第四个参数设置为 true。
发送包含自定义字段的电子邮件
$tokens = [
'custom_content' => 'This will value will be available in mautic as {custom_content}'
];
sendToContact($mail, $templateId, $tokens)
发送包含 HTML 内容的电子邮件
$tokens = [
'html_content' => '<span>This html content will not be escpaed</span>'
];
sendToContact($mail, $templateId, $tokens, true)
其他可用方法
getContactIdByMail($mail)
sendToLead($mail, $templateId, array $tokens = [], $html = false)
sendToContact($mail, $templateId, array $tokens = [], $html = false)