【发布时间】:2020-08-04 22:19:09
【问题描述】:
我买了 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',
谢谢。
【问题讨论】:
-
对于 site1 工作正常。但我也不知道如何将它保存在 site2 上,因为它是不同的 api,setup.php 中的不同域和 save.php 文件中的不同“id-my-list”(id- my-list1 和 id-my-list2)。
标签: php mysql api email web-development-server