Freepbx:以编程方式添加扩展

时间:2016-01-31 03:58:01

标签: freepbx

我试图以编程方式添加扩展名。在那里,我遇到了一些问题。我的代码是

Test 1: current process
Test 2: remote process (Handle)
Test 3: remote process (PID)
C:\Program Files\Python35\python.exe
C:\Windows\SYSTEM32\ntdll.dll
C:\Windows\system32\KERNEL32.DLL
C:\Windows\system32\KERNELBASE.dll
C:\Program Files\Python35\python35.dll
C:\Program Files\Python35\VCRUNTIME140.dll
C:\Windows\SYSTEM32\ucrtbase.dll
C:\Windows\system32\ADVAPI32.dll
C:\Windows\system32\WS2_32.dll
C:\Windows\system32\sechost.dll
C:\Windows\system32\RPCRT4.dll
C:\Windows\system32\NSI.dll
C:\Windows\system32\msvcrt.dll
C:\Windows\SYSTEM32\CRYPTBASE.DLL
C:\Windows\SYSTEM32\bcryptPrimitives.dll
C:\Windows\SYSTEM32\CRYPTSP.dll
C:\Windows\SYSTEM32\bcrypt.dll
C:\Windows\system32\rsaenh.dll
C:\Program Files\Python35\python3.dll
C:\Program Files\Python35\DLLs\_ctypes.pyd
C:\Windows\system32\ole32.dll
C:\Windows\system32\combase.dll
C:\Windows\system32\GDI32.dll
C:\Windows\system32\USER32.dll
C:\Windows\system32\OLEAUT32.dll
C:\Windows\system32\IMM32.DLL
C:\Windows\system32\MSCTF.dll

输出

<?php
$bootstrap_settings = array();
$bootstrap_settings['freepbx_auth'] = false;
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
  include_once('/etc/asterisk/freepbx.conf'); 
}

$vars = array(
"extension" => 9876543200,
    "name" => "Test",
    "devinfo_secret" => "testing",
    "devinfo_mediaencryption" => "sdes",
);

core_users_add($vars);
core_devices_add(9876543200,'pjsip','PJSIP/9876543200','fixed',9876543200,'Test');

我尝试添加PJSIP扩展,但在GUI中我添加了虚拟设备。我还需要添加媒体加密。谁能指导我?

1 个答案:

答案 0 :(得分:2)

我发现直接进入数据库更容易做到这一点。我没有用pjsip做任何事情,但这就是我创建一个sip扩展的方法。要想出来,最简单的方法是启用general log in MySQL并在创建用户时记录查询。之后,请务必重新加载。

INSERT INTO users (
    extension, password, name, voicemail, ringtimer, noanswer, recording,
    outboundcid, sipname, noanswer_cid, busy_cid, chanunavail_cid,
    noanswer_dest, busy_dest, chanunavail_dest, mohclass, auditor_exttype
)
VALUES (
    '12345', '', 'Test', 'novm', '0', '', '', '',
    'test', '', '', '', '', '', '', 'default', 99
);

INSERT INTO devices (
    id, tech, dial, devicetype, user, description, emergency_cid
)
VALUES
    ('12345', 'sip', 'SIP/12345', 'fixed', '12345', 'Test', '')
;

INSERT INTO sip (
    id, keyword, data, flags
)
VALUES
    ('12345', 'secret', 'supersecre†', 2),
    ('12345', 'dtmfmode', 'rfc2833', 3),
    ('12345', 'canreinvite', 'no', 4),
    ('12345', 'context', 'from-internal', 5),
    ('12345', 'host', 'dynamic', 6),
    ('12345', 'trustrpid', 'yes', 7),
    ('12345', 'sendrpid', 'yes', 8),
    ('12345', 'type', 'friend', 9),
    ('12345', 'nat', 'yes', 10),
    ('12345', 'port', '5060', 11),
    ('12345', 'qualify', 'yes', 12),
    ('12345', 'qualifyfreq', '60', 13),
    ('12345', 'transport', 'udp', 14),
    ('12345', 'avpf', 'no', 15),
    ('12345', 'icesupport', 'no', 16),
    ('12345', 'encryption', 'yes', 17),
    ('12345', 'callgroup', '', 18),
    ('12345', 'pickupgroup', '', 19),
    ('12345', 'disallow', '', 20),
    ('12345', 'allow', '', 21),
    ('12345', 'dial', 'SIP/12345', 22),
    ('12345', 'mailbox', '12345@device', 23),
    ('12345', 'deny', '0.0.0.0/0.0.0.0', 24),
    ('12345', 'permit', '0.0.0.0/0.0.0.0', 25),
    ('12345', 'account', '12345', 26),
    ('12345', 'callerid', 'device <12345>', 27)
;