Table of Contents |
---|
minLevel | 1 |
---|
maxLevel | 6 |
---|
outline | false |
---|
style | none |
---|
type | list |
---|
printable | false |
---|
|
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:
<extension name Code Block |
---|
<extension name="to-gateway"> |
|
<condition field="${destination number} expression="(.*)"> |
|
<action application="set" data="curl_timeout=1"/> <!-- Timeout Delay in Seconds --> |
|
<action application="curl" data="http://mywebserver.com/getnumber.php?number=${destination_number}&name=${url_encode(${caller_id_name})}"/> |
|
<action application="log" data="Dialing out on gateway:${curl_response_data} response-code:${curl_response_code}"/> |
|
<action application="bridge" data="sip/gateway/${curl_response_data}/${destination_number}/> |
|
Code Block |
Your Web Server should return a response like this:
Sample code
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.
...
So the generated SQL query is:
Code Block |
---|
SELECT <db_gateway_column> FROM <db_table> WHERE <db_number_column>=<number> |
|
For example, using this line from the dialplan:
Will result in this SQL query:
Code Block |
---|
SELECT gateway FROM gateways WHERE number=9054741990 |
|