escopecz/mautic-form-submit

一个用于从第三方PHP应用程序提交Mautic表单的库

2.0.0-alpha 2024-08-29 13:06 UTC

This package is auto-updated.

Last update: 2024-08-29 13:08:08 UTC


README

Scrutinizer Code Quality Build Status Code Coverage

如果您想通过您的应用程序处理数据,但同时也希望将它们发送到Mautic,则提交表单会很有用。Mautic可以运行由表单提交触发的自动化任务。在原始帖子中了解更多关于它

由于新版本的Mautic更倾向于使用Cookie跟踪而非IP跟踪,这使得作为跟踪联系人的表单提交变得更加繁琐。这个库将负责通过CURL发送Cookie。它还将监听响应中的Cookie,并使用提交响应中的值更新联系人的Cookie。这样,如果由于联系人合并导致联系人ID发生变化,联系人将继续以新的联系人ID浏览。

自动处理Cookie需要您的表单在由Mautic JS跟踪的页面上,该跟踪首先提供Mautic联系人Cookie。

安装

通过Composer

composer require escopecz/mautic-form-submit

用法

// Require Composer autoloader
require __DIR__.'/vendor/autoload.php';

// Define the namespace of the Mautic object
use Escopecz\MauticFormSubmit\Mautic;

// Define the namespace of the Mautic configuration object
use Escopecz\MauticFormSubmit\Mautic\Config;

// It's optional to declare the configuration object to change some default values.
// For example to disable Curl verbose logging.
$config = new Config;
$config->setCurlVerbose(true);

// Instantiate the Mautic object with the base URL where the Mautic runs
$mautic = new Mautic('https://mymautic.com');

// Create a new instance of the Form object with the form ID 342
$form = $mautic->getForm(342);

// Submit provided data array to the form 342
$result = $form->submit(['f_email' => 'john@doe.email']);
  • 传递给getForm()方法的整数必须是Mautic表单的ID。
  • 传递给submit()方法的数组必须是关联数组['mautic_field_alias' => 'the_value']

有关示例,请参阅examples目录。

运行项目

ddev start 

项目URL: https://mautic-form-submit.ddev.site/

测试

composer test
composer cs
composer phpstan

当前状态

Travis Scrutinizer

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。