Add Extension Programmatically

I was trying to add extension programatically. There I was facing some issues. My code was

<?php
$bootstrap_settings = array();
$bootstrap_settings['freepbx_auth'] = false;
if ([email protected]_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');

`
And output

[[email protected] html]# php a.php
[FATAL] Fields are empty

Trace Back:

/var/www/html/admin/modules/core/Core.class.php:1389 die_freepbx()
 [0]: Fields are empty

/var/www/html/admin/modules/core/functions.inc.php:4227 FreePBX\modules\Core->convertRequest2Array()
 [0]: 9876543200
 [1]: pjsip
 [2]: 2

/var/www/html/a.php:18 core_devices_add()
 [0]: 9876543200
 [1]: pjsip
 [2]: PJSIP/9876543200
 [3]: fixed
 [4]: 9876543200
 [5]: Test

I tried to add PJSIP extension but in GUI I was getting virtual device added.
I need to add media encryption also. Can anyone guide me?

Please state your version of freepbx. The guide you are following only works for 2.11

Freepbx Framework: 13.0.54
Core: 13.0.40

Can you guide me for recent version?

The 13 Bulk Handler module supports importing extensions via fwconsole arguments.
http://wiki.freepbx.org/pages/viewpage.action?pageId=37912685#fwconsolecommands(13+)-BulkImport

2 Likes

You made my day! Thanks a lot.

1 Like

Hello @lgaetz ,

Is there a way to edit or delete an extension with the bulkimport flag?

Thank you,

Daniel Friedman
Trixton LTD.