[asterisk-users] add new sip account in sip.conf with API Action UpdateConfig with php

virendra bhati virbhati at gmail.com
Mon May 21 07:10:49 CDT 2012


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: Login\r\n");
  fputs($socket, "UserName: admin\r\n");
  fputs($socket, "Secret: admin\r\n\r\n");

  fputs($socket, "Action: UpdateConfig\r\n");
  fputs($socket, "reload=yes\r\n");
  fputs($socket, "SrcFilename: additional_sip.conf\r\n");
  fputs($socket, "DstFilename: additional_sip.conf\r\n");
  fputs($socket, "Action-000000: NewCat\r\n");
  fputs($socket, "Cat-000000: 9911881985\r\n");
  fputs($socket, "Var-000000: 9911881985\r\n");
  fputs($socket, "Value-000000: 9911881985\r\n");
  fputs($socket, "ActionID: 343434\r\n\r\n");
  fputs($socket, "Action: Logoff\r\n");
  fputs($socket, "UserName: root\r\n");
  fputs($socket, "Secret: energy\r\n\r\n");

  $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>

-- 

Thanks and regards

 Virendra Bhati
+91-08885268942
Software Engineer
E-mail-: virbhati at gmail.com
Skype id:- virbhati2
Hyderabad(India)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120521/88a4bf72/attachment.htm>


More information about the asterisk-users mailing list