add new sip account in sip.conf with API Action UpdateConfig with php

Home » Asterisk Users » add new sip account in sip.conf with API Action UpdateConfig with php
Asterisk Users 1 Comment

Hi List,

I am trying to add new SIP account in new file additional_sip.conf. I read
in Wiki there is API command UpdateConfig which is used to update , add and
delete any entry from configure files. I am using PHP to make new entry in
additional_sip.conf. Below is the code which I tryed ….

< ?php
$socket = fsockopen(“127.0.0.1″,”5038”, $errno, $errstr, 30);
if (!$socket)
{
$done=0;
} else {
fputs($socket, “Action: Loginrn”);
fputs($socket, “UserName: adminrn”);
fputs($socket, “Secret: adminrnrn”);

fputs($socket, “Action: UpdateConfigrn”);
fputs($socket, “reload=yesrn”);
fputs($socket, “SrcFilename: additional_sip.confrn”);
fputs($socket, “DstFilename: additional_sip.confrn”);
fputs($socket, “Action-000000: NewCatrn”);
fputs($socket, “Cat-000000: 9911881985rn”);
fputs($socket, “Var-000000: 9911881985rn”);
fputs($socket, “Value-000000: 9911881985rn”);
fputs($socket, “ActionID: 343434rnrn”);
fputs($socket, “Action: Logoffrn”);
fputs($socket, “UserName: rootrn”);
fputs($socket, “Secret: energyrnrn”);

$done=1;
}

?>

*CLI Log:-*
ks3098819*CLI>
== Parsing ‘/etc/asterisk/manager.conf’: Found
== Manager ‘admin’ logged on from 127.0.0.1
== Manager ‘admin’ logged off from 127.0.0.1
ks3098819*CLI>

One thought on - add new sip account in sip.conf with API Action UpdateConfig with php

  • Hi,

    1- try putting absolute filepath in source and destination field.
    2- verify that the permissions of the files you’re changing.

    Regards,
    Sammy.