assignSubscribersToGroups

Description

Assign multiple subscribers to one or more groups. If the subscriber already exists, the new groups will be merged with the current ones.



Params

Name Type Description
apiKey string API key previously generated.
groups array An array with the id of the groups that you want to assign.
subscribers array An array with the email of the subscribers that you want to assign.

 

Returned data

Type: array

Description: Return an array with the number of inserted, updated and failed subscribers.

 

Json sample code

<?php

$curl = curl_init('https://your_address/ccm/admin/api/version/2/&type=json');

$postData = array(
    'function' => 'assignSubscribersToGroups',
    'apiKey' => 'apiKey',
    'groups' => array(
        1,
        2
    ),
    'subscribers' => array(
        'example1@gmail.com',
        'example2@gmail.com',
        'example3@gmail.com',
        '4'
    )
);

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$json = curl_exec($curl);
if ($json === false) {
    die('Request failed with error: '. curl_error($curl));
}

$result = json_decode($json);
if ($result->status == 0) {
    die('Bad status returned. Error: '. $result->error);
}

var_dump($result->data);

 

Result of API call

stdClass Object
(
    [insertedSubscribers] => 0
    [updatedSubscribers] => 3
    [failedSubscribers] => 0
)
Menu Title