如何将 1 个订阅者添加到多个 MailWizz(具有不同的 API 和域)?
How to add 1 subscriber to multiple MailWizz (with different APIs and domains)?
我买了 MailWizz,非常好。而且 API 非常容易使用:
https://github.com/twisted1919/mailwizz-php-sdk
https://api-docs.mailwizz.com/#subscribers-create
我需要的是将这个单个订阅者添加到 2 个不同域中的 2 个不同 API。但我不知道该怎么做,因为我只需要使用 1 个 setup.php 文件。
我只是用姓名和电子邮件字段创建了我的 HTML 时事通讯表单,并使用以下代码定向到 save.php 文件:
<?php
// require the setup which has registered the autoloader
require_once dirname(__FILE__) . '/setup.php';
// CREATE THE ENDPOINT
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
if (!empty($_POST)) {
// CREATE / UPDATE EXISTING SUBSCRIBER
$response = $endpoint->createUpdate('id-my-list', array(
'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : null,
'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : null
));
}
?>
setup.php
<?php// require the autoloader class if you haven't used composer to install the package
require_once dirname(__FILE__) . '/MailWizzApi/Autoloader.php';
// register the autoloader if you haven't used composer to install the package
MailWizzApi_Autoloader::register();
// configuration object
$config = new MailWizzApi_Config(array(
'apiUrl' => 'https://site1.com/mailwizz/api/',
'publicKey' => '0000000',
'privateKey' => '11111111',
// components
'components' => array(
'cache' => array(
'class' => 'MailWizzApi_Cache_File',
'filesPath' => dirname(__FILE__) . '/MailWizzApi/Cache/data/cache', // make sure it is writable by webserver
)
),
));
// now inject the configuration and we are ready to make api calls
MailWizzApi_Base::setConfig($config);
// start UTC
date_default_timezone_set('UTC');
?>
我有2个API
'apiUrl' => 'https://site1.com/mailwizz/api/',
'publicKey' => '0000000',
'privateKey' => '11111111',
and
'apiUrl' => 'https://other-site2.com/mailwizz-new/api/',
'publicKey' => '22222222',
'privateKey' => '333333333',
谢谢。
这可能对您有帮助:
<?php
require_once dirname(__FILE__) . '/MailWizzApi/Autoloader.php';
// register the autoloader if you haven't used composer to install the package
MailWizzApi_Autoloader::register();
date_default_timezone_set('UTC');
$sites = [
[
'list_uid' => 'xxx',
'config' => [
'apiUrl' => 'https://site1.com/mailwizz/api/',
'publicKey' => '0000000',
'privateKey' => '11111111',
]
],
[
'list_uid' => 'xxx',
'config' => [
'apiUrl' => 'https://other-site2.com/mailwizz-new/api/',
'publicKey' => '22222222',
'privateKey' => '333333333',
]
]
];
foreach ($sites as $site) {
$config = new MailWizzApi_Config($site['config']);
MailWizzApi_Base::setConfig($config);
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->createUpdate($site['list_uid'], array(
'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : '',
'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : ''
));
}
虽然示例使用了 setup.php
文件,但这并不意味着您也必须使用它。这只是一个例子。
我买了 MailWizz,非常好。而且 API 非常容易使用:
https://github.com/twisted1919/mailwizz-php-sdk
https://api-docs.mailwizz.com/#subscribers-create
我需要的是将这个单个订阅者添加到 2 个不同域中的 2 个不同 API。但我不知道该怎么做,因为我只需要使用 1 个 setup.php 文件。
我只是用姓名和电子邮件字段创建了我的 HTML 时事通讯表单,并使用以下代码定向到 save.php 文件:
<?php
// require the setup which has registered the autoloader
require_once dirname(__FILE__) . '/setup.php';
// CREATE THE ENDPOINT
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
if (!empty($_POST)) {
// CREATE / UPDATE EXISTING SUBSCRIBER
$response = $endpoint->createUpdate('id-my-list', array(
'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : null,
'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : null
));
}
?>
setup.php
<?php// require the autoloader class if you haven't used composer to install the package
require_once dirname(__FILE__) . '/MailWizzApi/Autoloader.php';
// register the autoloader if you haven't used composer to install the package
MailWizzApi_Autoloader::register();
// configuration object
$config = new MailWizzApi_Config(array(
'apiUrl' => 'https://site1.com/mailwizz/api/',
'publicKey' => '0000000',
'privateKey' => '11111111',
// components
'components' => array(
'cache' => array(
'class' => 'MailWizzApi_Cache_File',
'filesPath' => dirname(__FILE__) . '/MailWizzApi/Cache/data/cache', // make sure it is writable by webserver
)
),
));
// now inject the configuration and we are ready to make api calls
MailWizzApi_Base::setConfig($config);
// start UTC
date_default_timezone_set('UTC');
?>
我有2个API
'apiUrl' => 'https://site1.com/mailwizz/api/',
'publicKey' => '0000000',
'privateKey' => '11111111',
and
'apiUrl' => 'https://other-site2.com/mailwizz-new/api/',
'publicKey' => '22222222',
'privateKey' => '333333333',
谢谢。
这可能对您有帮助:
<?php
require_once dirname(__FILE__) . '/MailWizzApi/Autoloader.php';
// register the autoloader if you haven't used composer to install the package
MailWizzApi_Autoloader::register();
date_default_timezone_set('UTC');
$sites = [
[
'list_uid' => 'xxx',
'config' => [
'apiUrl' => 'https://site1.com/mailwizz/api/',
'publicKey' => '0000000',
'privateKey' => '11111111',
]
],
[
'list_uid' => 'xxx',
'config' => [
'apiUrl' => 'https://other-site2.com/mailwizz-new/api/',
'publicKey' => '22222222',
'privateKey' => '333333333',
]
]
];
foreach ($sites as $site) {
$config = new MailWizzApi_Config($site['config']);
MailWizzApi_Base::setConfig($config);
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->createUpdate($site['list_uid'], array(
'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : '',
'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : ''
));
}
虽然示例使用了 setup.php
文件,但这并不意味着您也必须使用它。这只是一个例子。