Service: CreatePreferenceSubscription

The CreatePreferenceSubscription service allows you to create a new preference subscription within Flexmail, add an email address to a preference.

Service Details

SOAP Action: CreatePreferenceSubscription
SOAP Return Object: CreatePreferenceSubscriptionResp

Input

The following table describes the parameters used for calling the CreatePreferenceSubscription service.

Table: instance of CreatePreferenceSubscriptionReq

Parameter Mandatory Type Description
header Y APIRequestHeader Header for authentication
preferenceSubscriptionType Y PreferenceSubscriptionType Contains preference and email address information

Output

The following table describes the parameters returned from the CreatePreferenceSubscription service.

Table: instance of CreatePreferenceSubscriptionResp

Parameter Mandatory Type Description
header / APIResponseHeader Header containing authentication information
errorCode / Integer Numerical value of the error
errorMessage / String Short literal description of the error

Table: response codes of CreatePreferenceSubscriptionResp.

0 No error
220 Authentication error, see header object for detailed information
221 Invalid flexmail id
222 Invalid email address object
223 Invalid preference id
224 Preference already linked to email address
225 Internal error

Example

This example shows you the creation of a new PreferenceSubscription within Flexmail, email address with id 257 will be added to the preference with id 33.

<?php
$header->userId = USER_ID;
$header->userToken = USER_TOKEN;

$createPreferenceSubscriptionReq->header = $header;
$createPreferenceSubscriptionReq->preferenceSubscriptionType->preferenceId = 33;
$createPreferenceSubscriptionReq->preferenceSubscriptionType->emailAddressFlexmailId = 257;
$createPreferenceSubscriptionResp = $SoapClient->__soapCall("CreatePreferenceSubscription", array($createPreferenceSubscriptionReq));

if ($createPreferenceSubscriptionResp->errorCode == 0) {
	echo "Prefrence Subscription created";
} else {
	echo "Preference subscription failed: " . $createPreferenceSubscriptionResp->errorMessage;
}
?>