List The Lists a Contact Is Subscribed To

This request will return a subset of all the lists a contact is subscribed to. You can include the page, count, order, direction, and filter variables to affect the list you receive.


The Method

API Method
RESTGEThttp://[Your URL]/api/2.0/contact_subscriptions/:contact_id
XML-RPCCallcontacts.ContactSubscriptions
Your URL is the address of your Everlytic install.

Your method must be structured as follows:

ContactSubscriptions(int $contact_id, int $page, int $count, string $order, string $direction, \struct | array $filters) : array

Parameters

Required Parameters

The only required parameter for this request is the $contact_id.

PropertyTypeDescriptionDefaultRequiredRead Only
$contact_idintegerThe ID of the contact you are querying.yes

Optional Parameters

The following parameters are optional:

PropertyTypeDescriptionRequired
$pageintegerThe page number of the list.no
$countintegerThe number of results to return per page.no
$orderstringThe name of the field to order the listing with.no
$directionstringThe direction to order the results in ('asc' or 'desc').no
$filtersstructarrayThe fields to filter on.no

Responses

TypeDescription
arrayAn array of contacts.

Code Samples

PHP (using REST API)

Tutorial

The rest of this document describes the example above, step-by-step.

In our Getting Started section we covered the four important components of an API request; URL, method, headers, and body.

RequestStructure

Let's analyse the code sample above to determine where each line fits into this outline.

1. Load the Everlytic API

The following line of code tells the server which API URL to access for the request:

$url = '(Your URL)/api/2.0/contact_subscriptions/:contact_id';

Your URL is the URL of your Everlytic installation.

2. Method

In this line of code, you tell the API which REST function to use:

$method = 'GET';

3. cURL

cURL is a tool for sending and receiving files from a web server. This line of code initialises the cURL session.

$cSession = curl_init();

4. Initiate the Headers

This section of the code opens the headers section and passes the authentication (including your API key).

$headers = array();

$auth = base64_encode($username . ':' . $apikey);

$headers[] = 'Authorization: Basic ' . $auth;

5. Set various cURL options for the session

These lines of code tell the server that we're using cURL to transfer data.

curl_setopt($cSession, CURLOPT_URL, $url);

curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);

curl_setopt($cSession, CURLOPT_HEADER, false);

curl_setopt($cSession, CURLOPT_CUSTOMREQUEST,

strtoupper($method));

curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);

6. Output the API response

$result = curl_exec($cSession);

7. Close the cURL session

curl_close($cSession);
Translate »