I’m having issues adding a subscriber to a specific addressbook in dotmailer using nusoap. I’ve no problem adding a generic subscriber to all contacts using the CreateContact method however when I try and use the AddContactToAddressbook method, I just doesn’t work.
The if statement used at the bottom returns successful, however nothing exists in the $result variable.
<?php
function subscribe($email, &$result)
{
global $postURL, $username, $password;
$addressBookId = "######";
$contact = array("Email" => $email, "EmailType" => "Html");
$params = array("username" => $username, "password" => $password, "contact" => $contact, "addressbookId" => $addressBookId);
$client = new soapclient($postURL, true);
$error = $client->getError();
$result = $client->call('AddContactToAddressbook', $params);
if($client->fault) {
$rv = false;
} else {
// Check for errors
if($error) {
$rv = false;
} else {
$rv = true;
}
}
return $rv;
}
if(subscribe("test@test.com", $result)) {
echo "success<br />";
print_r($result);
} else {
echo "failed<br />";
}
?>
This code works as is with only changing
$result = $client->call('AddContactToAddressbook', $params);
to
$result = $client->call('CreateContact', $params);
But then the subscriber is not in any particular list. Does anyone know what I might be doing wrong.
p.s. the $addressBookId variable has been blanked out intentionally, I didn’t try to run it with ‘######’ as the value in case you were wondering.
And once in production the $result variable will not be returned with the function.
Thanks
use
$result = $client->call('AddContactToAddressBook', $params);capital
Bon book