very nice job,
except there are a few catches,
it is easier for the user just type the destination number inside the text
and send it
therefore I had to change the keyword from callback to default
also + in front created some problems and the date which was wrong causes immidiate hangup,
so we had to correct the callerID and the call initiation date to current date
you also have to change the url to :
Code:
"http://server.address.com/api/SOAP/sms-callback.php?n=%q&dest=%a"
then change the code to below.
sms-callback
Code:
<?php
//#!/usr/bin/php -q
/***************************************************************************
*
* sms-callback.php : PHP A2Billing - SMS Callback Soap Client
* Written for PHP 5.X versions. Might work with PHP 5+
* Copyright (C) 2007 Abdoulaye Siby <asiby _atl_ gmail com>
*
* A2Billing -- Asterisk billing solution.
* Copyright (C) 2004, 2007 Belaid Arezqui <areski _atl_ gmail com>
*
* See http://www.asterisk2billing.org for more information about
* the A2Billing project.
* Please submit bug reports, patches, etc. regarding this file to <asiby _atl_ gmail com>
* For all other bug reports, patches, etc. submit them to <areski _atl_ gmail com>
*
* This software is released under the terms of the GNU Lesser General Public License v2.1
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
*
****************************************************************************/
/***************************************************************************
*
* USAGE : http://your.server.here/A2Billing_ADMIN_PATH/api/SOAP/sms-callback.php?n=phone_number_to_be_called_back
*
****************************************************************************/
$allowed_hosts = array(
'127.0.0.1',
// '10.1.2.26',
// '10.1.1.101',
);
// Please replace xx.xx.xx.xx with any valide IP of any hosts that are allowed to have access to this script.
// Note that the trailing coma in the array is not a typo.
if(in_array($_SERVER['REMOTE_ADDR'], $allowed_hosts)){
// This will reject any access attempts being made from outside your box. You can add any IP of any
exit;
}
error_reporting(E_ALL ^E_NOTICE);
ini_set("display_errors", "on");
if ($argc > 1 && ($argv[1] == '--version' || $argv[1] == '-v'))
{
echo "A2Billing - SOAP CLI Callback Server Version 1.0\n";
exit;
}
$callback_number = str_replace("+","", trim($_GET['n']));
$destination_number = trim($_GET['dest']);
//mod by mohammad, check if there is anything except number in dnid, if yes exchange the
if ( (substr($destination_number,0,2) <> "00" ) or (strlen($destination_number) < 5) or
( (strlen(preg_replace("/[^0-9]/","", $destination_number))) < (strlen($destination_number)) )) {
$destination_number = $callback_number;
}
if (!is_numeric($callback_number)){
echo "Bad request\n";
exit(1);
}
include ("../../lib/defines.php");
$security_key = API_SECURITY_KEY;
// echo "$security_key<br />". md5($security_key).'<br />';
$endpoint = 'http://admin.server.address.com/api/SOAP/callback-server.php';
$client = new SoapClient(null, array(
'location' => $endpoint,
'uri' => 'urn://admin.server.address.com/api/SOAP',
'trace' => 1,
'exceptions' => 1,
'encoding' => 1,
)
);
$fault = null;
// ADD ON THE SPEC SECURITY KEY
// echo "<hr>############# Request CallBack ############# <hr>";
$method = 'Request';
$params = array(
'security_key' => md5($security_key),
'called' => $callback_number,
'calling' => $destination_number,
'callerid' => $callback_number,
'callback_time' => date("Y-m-d H:i:s", mktime()), /* 2007-09-25 01:00:00, Don't worry about this for now. It's work anyway */
'uniqueid' => '', /* No sweat. It will be generated automatically */
);
list($result, $status, $details) = $client->__soapCall($method, $params);
echo "Result (insert_id_callback): $result\nStatus: $status\nDetails: $details\n\n";
// echo "<hr>############# Check Status ############# </hr>";
$method = 'Status';
$insert_id_callback = $result;
$params = array(
'security_key' => md5($security_key),
'id' => $insert_id_callback,
);
list($result, $status, $details) = $client->__soapCall($method, $params);
echo "Result (Status): $result\nStatus: $status\nDetails: $details\n\n";