getGroups

Description

Get list of groups.



Params

NameTypeDescription
apiKeystringAPI key previously generated.
offsetintegerOptional parameter to specify offset.
countintegerOptional parameter to specify the number of records.
idintegerOptional parameter to search by id.
namestringOptional parameter to search by name.
descriptionstringOptional parameter to search by description.
positionintegerOptional parameter to search by position.
enablebooleanOptional parameter to search if group is enabled.
visiblebooleanOptional parameter to search if group is visible.
sortFieldstringOptional parameter to specify a search field.
sortOrderstringOptional parameter to specify a sort order. Accepted values are ASC and DESC (default).

 

Returned data

Type: array

Description: Return array with groups data.

 

Json sample code

<?php

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

$postData = array(
    'function' => 'getGroups',
    'apiKey' => 'apiKey',
    'offset' => 0,
    'count' => 2,
);

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

Array
(
    [0] => stdClass Object
        (
            [id] => 15
            [position] => 0
            [name] => API 2012-02-16 13:06:20
            [description] => 
            [enable] => 1
            [visible] => 0
        )

    [1] => stdClass Object
        (
            [id] => 14
            [position] => 0
            [name] => API 2012-02-16 13:06:03
            [description] => 
            [enable] => 1
            [visible] => 0
        )

)