Пример #1
0
 $DEVICE_TEMPLATE['suppress_unregister_notifications'] = false;
 $DEVICE_TEMPLATE['call_forward'] = array('enabled' => false, 'number' => '', 'require_keypress' => false, 'keep_caller_id' => true, 'substitute' => false, 'ignore_early_media' => true, 'direct_calls_only' => false);
 $DEVICE_TEMPLATE['caller_id']['internal'] = array('number' => '1234', 'name' => 'test person');
 $DEVICE_TEMPLATE['caller_id']['external'] = array('number' => '1234', 'name' => 'test person');
 $DEVICE_TEMPLATE['media'] = array('fax' => array('option' => 'auto'), 'bypass_media' => 'false');
 $DEVICE_TEMPLATE['media']['audio']['codecs'][] = "PCMA";
 $DEVICE_TEMPLATE['media']['audio']['codecs'][] = "PCMU";
 $DEVICE_TEMPLATE['sip'] = array('method' => 'password', 'invite_format' => 'username', 'username' => $USER_TEMPLATE['username'], 'password' => substr(sha1($USER_TEMPLATE['username']), 0, 31), 'expire_seconds' => 300, 'registration_expiration' => 360);
 printf("{$bldblu}TEST: Create Device.{$txtrst}\n");
 $DEVICE_TEMPLATE['owner_id'] = $USER_ID;
 $resp = $XBAR->put_device($DEVICE_TEMPLATE, $ACCOUNT_ID);
 if ($resp['status'] == 'success') {
     printf("{$bldgrn}PASS: Create Device.{$txtrst}\n\n");
     $DEVICE_ID = $resp['data']['id'];
     printf("{$bldblu}TEST: Get Device by ID:{$bldred}{$DEVICE_ID}.{$txtrst}\n");
     $device = $XBAR->get_device($DEVICE_ID, $ACCOUNT_ID);
     if (isset($device['id'])) {
         printf("{$bldgrn}PASS: Get Device.{$txtrst}\n\n");
     } else {
         printf("{$bldred}FAIL: Get Device.{$txtrst}\n\n");
     }
     printf("{$bldblu}TEST: Delete Device{$txtrst}\n");
     $resp = $XBAR->del_device($DEVICE_ID, $ACCOUNT_ID);
     if ($resp['status'] == "success") {
         printf("{$bldgrn}PASS: Delete Device.{$txtrst}\n\n");
     } else {
         printf("{$bldred}FAIL: Delete Device.{$txtrst}\n\n");
     }
 } else {
     printf("{$bldred}FAIL: Create Device.{$txtrst}\n\n");
 }