subscribeContact

Subscribes a single Contact to a List.

subscribeContact

Subscribes a single Contact to a List.

Top ↑

Syntax

int subscribeContact(
    string api_key,
    int list_id,
    array contact_details 
);

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

list_id (int)

The ID of the List to subscribe the Contact to.

contact_details (array)

An associative arrays of Contact details, indexed using each of the Field names in the List. See the examples below.

Return Value

Returns the ID of the subscribed Contact on success.

Examples

The example shows how to use subscribeContact to subscribe a new Contact to a List.

$list_id = 1234567;     // can be obtained using searchLists()

$contact_details = array(
    'Email'         => 'bob@example.com',
    'Mobile Phone'  => '0404555555',
    'Name'          => 'Bob Jones'
);

$api = new Api($url, 'YOURAPIKEY');
$contact_id = $api->invokeMethod('subscribeContact', $list_id, $contact_details);
{
    "id": 1,
    "method": "subscribeContact",
    "params": [
        "YOURAPIKEY",
        1234567,
        {
            "Email": "bob@example.com",
            "Mobile Phone": "0404555555",
            "Name": "Bob Jones"
        }
    ]
}
{
    "id": 1,
    "result": 32,
    "error": null
}

Remarks

When a contact is successfully subscribed, the system will:

  • Trigger associated Subscribe Campaign Events or Autoresponders.
  • Send a notification message to each address in the on_register_address value for the List (see addList).

Use addContacts for adding multiple Contacts to a List.

The API does not check the mandatory value of List Fields when adding or editing Contacts.

Error Codes

This method may return the following error codes in addition to the standard error codes:

Code Error Description
303 Unable to Load List list_id is not a valid List
310 Invalid Method Parameters contact_details must be a single array of Contact details
330 Contact Limit Reached The Contact limit for the Account has been reached
317 Invalid Email Address Specified The supplied Email address is not valid
302 Undefined Error: Contact Subscription Failed An internal error occurred while the system was trying to subscribe the Contact

See Also