Outbound SIP Trunks
The dialplan can be configured to perform HTTP requests and route the call based on the HTTP response.
To do this, you will need to use the curl application inside your call routing table to perform the HTTP request. The return value from the HTTP request will be stored in the variable curl_response_data, and return code curl_response_code.
Example call routing:
Your Web Server should return a response like this:
A sample php code that you can use for debug can be downloaded from this link:
Sample Test PHP script
The sample code will always return 'gateway1'.
Sample code to query database
The webserver can be extended to retrieve the gateway name from a database.
You can download the sample PHP code that will connect to a MySQL Database from the link below:
Sample PHP Script
The sample PHP script accepts the following parameters:
db_url: URL of database to connect to. Default: localhost
db_user: Username to connect to database. Default: root
db_password: Password to connect to database. Default: sangoma
db_name: Database name. Default: sangoma_sbc
db_table: Table name. Default: gateways
db_number_column: Name of column that contains the number to look-up. Default: number
db_gateway_column: Name of column that contatins the gateway name. Default: gateway
So the generated SQL query is:
SELECT <db_gateway_column> FROM <db_table> WHERE <db_number_column>=<number>
For example, using this line from the dialplan:
<action application="curl" data="http://localhost/getgateway.php?
Will result in this SQL query:
SELECT gateway FROM gateways WHERE number=9054741990