[inbound_transf_exten]
exten=>_x.,1,Noop( DID ---${EXTEN}--- and CALLERID ---${CALLERID(num)})
same=>n,agi(/var/www/html/call_transfer.php,${EXTEN},${CALLERID(num)})
same=>n,GotoIf($["${receiver}" = ""]?from-trunk,*788${EXTEN},1)
same => n,NoOp(My action is: ${action})
same => n,NoOp(My receiver is: ${receiver})
same => n,NoOp(My duration is: ${duration})
same => n,NoOp(My language is: ${lang})
same => n,NoOp(My language is: ${cid_name})
same => n,NoOp(My language is: ${cid_number})
same => n,NoOp(My filename is: ${filename})
same=>n,Set(CALLERID(all)=${cid_name}<${cid_number}>)
same=>n,GotoIf($["${duration}" = ""]?from-internal,${receiver},1)
;same=>n,goto(from-internal,${receiver},1)
same=>n,set(LIMIT_WARNING_FILE=${filename})
same=>n,Set(LIMIT_PLAYAUDIO_CALLER=yes)
same=>n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)
same=>n,Set(LIMIT_TIMEOUT_FILE=)
same=>n,Dial(Local/${receiver}@from-internal,,L(${duration}:${start_sound}:))
same=>n,hangup()
................
#!/usr/bin/php
<?php
// Check if command line arguments are provided
if ($argc < 3) {
echo "Usage: php script.php [DID] [CID]\n";
exit(1);
}
// Get DID and CID from command line arguments
$did = $argv[1];
$cid = $argv[2];
// Construct the URL
$url = "https://hub.servcenter.net/api/call_rules/rules/in/1/$did/$cid";
// Read JSON data from the URL
$jsonData = file_get_contents($url);
// Check if JSON data is successfully fetched
if ($jsonData === false) {
echo "Error: Unable to fetch JSON data from URL.\n";
exit(1);
}
// Decode the JSON data
$data = json_decode($jsonData, true);
// Check if JSON decoding was successful
if ($data !== null) {
// Check if "rule" key exists and is an array
if (isset($data['rule']) && is_array($data['rule'])) {
// Loop through each key-value pair in the "rule" array
foreach ($data['rule'] as $key => $value) {
//echo "$key=> $value\n";
echo "SET VARIABLE $key \"$value\"\n";
}
} else {
echo "Error: 'rule' key not found or not an array in JSON data.\n";
}
{"total":2,"rule":{"action":"transfer","receiver":"1220","duration":false,"start_sound":false,"lang":null,"filename":null,"cid_name":"CB FRANCE","cid_number":"33-8140"}}