Vision 6

getMessagesSentToContact

Returns a list of Messages sent to the specified Contact.

getMessagesSentToContact

Returns a list of Messages sent to the specified Contact.

Top ↑

Syntax

array getMessagesSentToContact(
    string api_key,
    int list_id,
    int contact_id,
  [ string message_type,
    int period_from,
    int period_to ] 
);

API Key Access Level required: Limited access

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 containing the Contact.

contact_id (int)

The ID of the Contact.

message_type (string - optional)

The type of Messages to retrieve. Valid values are:

  • all (default)
  • email
  • sms
period_from (int - optional)

The lower timestamp in a time range of Messages to return.

period_to (int - optional)

The higher timestamp in a time range of Messages to return.

Return Value

Returns an array containing zero or more associative arrays. See the remarks section below for the list of values this method returns.

An empty array is returned if no Messages were sent to the Contact during the specified period.

Examples

The following code gets details of Email Messages sent to Contact 234 in List 1234567.

PHP

$list_id = 1234567;     // See searchLists()
$contact_id = 234;      // See searchContacts()

$period_from = strtotime('2012-08-01');
$period_to = strtotime('2012-10-01');

$api = new Api($url, 'YOURAPIKEY');
$messages_sent = $api->invokeMethod('getMessagesSentToContact', $list_id, $contact_id, 'email', $period_from, $period_to);

// loop over result
foreach ($messages_sent as $send_details) {
    print $send_details['name'] ." was sent to Contact ". $contact_id ."\n";
}

JSON Request

{
    "id": 1,
    "method": "getMessagesSentToContact",
    "params": [
        "YOURAPIKEY",
        1234567,
        234,
        "email",
        1343743200,
        1349013600
    ]
}

JSON Response

{
    "id": 1,
    "result": [
        {
            "id": 1036976,
            "message_id": 111222,
            "batch_id": 23456789,
            "message_type": "email",
            "name": "August Newsletter",
            "send_time": 1344390092,
            "first_open_time": 0,
            "last_open_time": 0,
            "open_type": "not_opened"
        }
    ],
    "error": null
}

Remarks

The following table shows the values that are returned.

Key Type Description
id int Send ID.
name string Name of the Message sent to the Contact.
batch_id int The Batch ID of the send.
first_open_time int Timestamp indicating the first time the Contact opened the message.
last_open_time int Timestamp indicating the last time the Contact opened the message.
message_id int The ID of the Message.
message_type string The type of the Message (either email or sms).
open_type string How the message was opened. Valid values are html, text, sms or not_opened.
send_time int Timestamp indicating when the Message was sent to the Contact.

Error Codes

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

Code Error Description
303 Unable to Load List list_id is not a valid List

See Also