<div dir="ltr">Hi List,<br><br>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 ....<br>
<br><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><?php</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 30);</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> if (!$socket) </span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> {</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> $done=0;</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> } else {</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Action: Login\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "UserName: admin\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Secret: admin\r\n\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> </span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Action: UpdateConfig\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "reload=yes\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "SrcFilename: additional_sip.conf\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "DstFilename: additional_sip.conf\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Action-000000: NewCat\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Cat-000000: 9911881985\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Var-000000: 9911881985\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Value-000000: 9911881985\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "ActionID: 343434\r\n\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Action: Logoff\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "UserName: root\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> fputs($socket, "Secret: energy\r\n\r\n");</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> $done=1;</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> }</span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)"><span style="background-color:rgb(255,255,255);color:rgb(51,204,255)"> </span><br style="background-color:rgb(255,255,255);color:rgb(51,204,255)">
<span style="background-color:rgb(255,255,255);color:rgb(51,204,255)">?></span><br clear="all"><br><b>CLI Log:-</b><br>ks3098819*CLI><br> == Parsing '/etc/asterisk/manager.conf': Found<br> == Manager 'admin' logged on from 127.0.0.1<br>
== Manager 'admin' logged off from 127.0.0.1<br>ks3098819*CLI><br><br>-- <br><div dir="ltr"><br>Thanks and regards<br><br> Virendra Bhati<br>+91-08885268942<br>Software Engineer<br>E-mail-: <a href="mailto:virbhati@gmail.com" target="_blank">virbhati@gmail.com</a><br>
Skype id:- virbhati2<br>Hyderabad(India)<br></div><br>
</div>