sip_add_account.php

Tijmen de Mes, 10/11/2012 07:50 pm

Download (997 Bytes)

 
1
#!/usr/bin/php
2
<?
3
include("SOAP/Client.php");   // Available in PHP PEAR SOAP library
4
require("ngnpro_soap_lib.php"); 
5

    
6
// Initialize SOAP client / SIP port
7
$SipPort = new WebService_NGNPro_SipPort();
8

    
9
// Login credentials to Managed DNS
10
$credentials = array("username"=>"MDNSusername","password"=>"MDNSpassword");
11
$auth_header = array('auth', $credentials , 'urn:AGProjects:NGNPro', 0, '');
12

    
13
//////////////////////////////////////////////
14
// Create a SIP account
15
//////////////////////////////////////////////
16

    
17
$SipPort->addHeader($auth_header);
18
$result=$SipPort->addAccount(array("id" => array("username" => 'alice',"domain"=> 'example.com'),"password"=> "1234"));
19
if (PEAR::isError($result)) {
20
    $error_msg=$result->getMessage();
21
    $error_fault=$result->getFault();
22
    $error_code=$result->getCode();
23
    print "$error_msg\n";
24
    printf ("%s %s\n",$error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring);
25
} else {
26
    print "SIP account created\n";
27
}
28

    
29
?>