*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/../lib/AAB/AABService.php';
use Att\Api\AAB\AABService;
$arr = null;
try {
    envinit();
    $aabService = new AABService(getFqdn(), getSessionToken());
    $gid = $_POST['getContactsGroupId'];
    if ($gid === '') {
        throw new Exception('Group Id must not be empty');
    }
    $contactIds = $aabService->getGroupContacts($gid);
    $values = array();
    foreach ($contactIds as $cid) {
        $values[] = array($cid);
    }
    $tables = array(array('caption' => 'Contacts:', 'headers' => array('contactId'), 'values' => $values));
    $arr = array('success' => true, 'tables' => $tables);
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 private function _handleGetGroupContacts()
 {
     $vnames = array('getGroupContacts', 'groupId');
     $this->copyToSession($vnames);
     if (!isset($_SESSION['getGroupContacts'])) {
         return;
     }
     $gid = $_SESSION['groupId'];
     try {
         $aabSrvc = new AABService($this->apiFQDN, $this->getSessionToken());
         $result = $aabSrvc->getGroupContacts($gid);
         $this->results[C_GET_GROUP_CONTACTS] = $result;
         $this->clearSession($vnames);
     } catch (Exception $e) {
         $this->errors[C_MANAGE_GROUPS_ERROR] = $e->getMessage();
         $this->clearSession($vnames);
     }
 }