( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
// require the setup which has registered the autoloader
require_once 'setup.php';
// and if it is and we have post values, then we can proceed in sending the subscriber.
if ( !empty($_POST)) {
$listUid = 'gc10198bct8df';// you'll take this from your customers area, in list overview from the address bar.
$endpoint = new EmsApi\Endpoint\ListSubscribers();
$response = $endpoint->create($listUid, [
'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : null,
'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : null,
'LNAME' => isset($_POST['LNAME']) ? $_POST['LNAME'] : null,
'CATALOGNAME' => isset($_POST['CATALOGNAME']) ? $_POST['CATALOGNAME'] : null,
'CATALOGID' => isset($_POST['CATALOGID']) ? $_POST['CATALOGID'] : null,
'ID' => isset($_POST['ID']) ? $_POST['ID'] : null,
'NEWSLETTER' => isset($_POST['NEWSLETTER']) ? $_POST['NEWSLETTER'] : null,
'WEBSITE' => isset($_POST['WEBSITE']) ? $_POST['WEBSITE'] : null,
'PHONE' => isset($_POST['PHONE']) ? $_POST['PHONE'] : null,
'TYPE' => isset($_POST['TYPE']) ? $_POST['TYPE'] : null,
'NAME' => isset($_POST['NAME']) ? $_POST['NAME'] : null,
'COUNTRY' => isset($_POST['COUNTRY']) ? $_POST['COUNTRY'] : null,
'OAUTH_PROVIDER' => isset($_POST['OAUTH_PROVIDER']) ? $_POST['OAUTH_PROVIDER'] : null,
'TIMESTAMP' => isset($_POST['TIMESTAMP']) ? $_POST['TIMESTAMP'] : null,
'CREATOR' => isset($_POST['CREATOR']) ? $_POST['CREATOR'] : null
]);
$response = $response->body;
// if the returned status is success, we are done.
if ($response->itemAt('status') == 'success') {
exit(json_encode([
'status' => 'success',
'message' => 'Thank you for joining our email list. Please confirm your email address now!'
]));
}
// otherwise, the status is error
exit(json_encode([
'status' => 'error',
'message' => $response->itemAt('error')
]));
}
?>