mtcextendee/mautic-badge-generator-bundle

此包最新版本(1.9.3)没有提供许可证信息。

1.9.3 2019-10-11 08:17 UTC

This package is auto-updated.

Last update: 2024-09-23 18:32:25 UTC


README

来自 Mautic 扩展家族的插件(https://mtcextendee.com

下载 7 个终极免费 Mautic 邮件主题 https://mtcextendee.com/themes/

通常,插件可以修改任何 PDF 文件,并添加新的文本自定义插槽和条形码。这对于您的活动非常有用。

功能

  • 添加自定义文本插槽到 PDF
    • 自定义联系人字段
    • 自定义字体大小、颜色和位置
  • 将条形码添加到 PDF
  • 将 QRcode 添加到 PDF
  • 令牌支持 - 使用链接到电子邮件/页面上的徽章({badge=1}
  • 在下载后生成 PDF 后添加到阶段
  • 从联系人列表为每个联系人生成自定义 PDF
  • 仅针对具有特定标签的联系人显示徽章生成器捆绑包

安装

通过命令行安装

  1. composer require mtcextendee/mautic-badge-generator-bundle
  2. php app/console mautic:plugins:reload

不允许手动安装,因为插件依赖于另一个 setasign/fpdi-tcpdf,该软件会自动从命令行安装。

设置

只需转到插件并启用新的 BadgeGenerator 集成。然后您应该会在左侧菜单中看到新列。

image

生成 PDF

在联系人列表中

image

之前

image

之后

image

API

库: https://github.com/mautic/api-library

钩子

$api = new \Mautic\Api\Api($auth, $apiUrl);
$contactId = 1;
$badgeId = 2;
$response = $api->makeRequest(sprintf("badge/generator/%d/%d", $contactId, $badgeId));

基本授权示例

// Bootup the Composer autoloader
include __DIR__.'/vendor/autoload.php';

use Mautic\Auth\ApiAuth;

$apiUrl = 'http://mautic.site';
$settings = [
    'userName' => 'admin',
    'password' => 'mautic',
];
$initAuth = new ApiAuth();
$auth     = $initAuth->newAuth($settings, 'BasicAuth');
$api = new \Mautic\Api\Api($auth, $apiUrl);
$contactId = 1;
$badgeId = 2;
$response = $api->makeRequest(sprintf("badge/generator/%d/%d", $contactId, $badgeId));
if (isset($response['pdf'])) {
$result = base64_decode($response['pdf']);
// Write on file
file_put_contents('test.pdf', $result);
echo 'PDF created';
} elseif (isset($response['errors'][0]['message'])) {
echo $response['errors'][0]['message'];
}

响应

  • 如果联系人有徽章

$response['pdf'] = 'PDF内容的 base64 编码';

您需要对 PDF 内容进行 base64decode,然后处理它(显示或保存等)。更多信息请查看:https://selectpdf.com/web-html-to-pdf-rest-api-for-php-samples/

  • 如果徽章或联系人不存在

$response['errors']