MySQLは、アスタリスクDialplans、通話転送通話転送
質問
どうやっていけばいいですか?印して着信に基づくマッチングし、着信番号として何ですか?両番号保管中にMySQLデータベースです。
解決 3
解決のた年のようになります:
[default]
exten => _X.,1,Set(ARRAY(${EXTEN}_phone)=${DTC_ICF(phone_number,${EXTEN})})
exten => _X.,n(callphone),Dial(SIP/metaswitch/${${EXTEN}_phone},26)
exten => _X.,n(end),Hangup()
他のヒント
申し訳のサンプルコードが半分以上のデバッグコードをご用意しています。
思想サーバはすでに現代版PHPで /usr/bin/php
を試しいデータベースのテーブル名 fwd_table
柱 caller_id
や destination
.
/Var/lib/スタリスク/agi-binコピーを取得し、 PHP AGI 図書館があります。アレイの作製という名前のファイルのようなもの forward_by_callerid.agi
を決めます。
#!/usr/bin/php
<?php
ini_set('display_errors','false'); //Supress errors getting sent to the Asterisk process
require('phpagi.php');
$agi = new AGI();
try {
$pdo = new PDO('mysql:host='.$db_hostname.';dbname='.$db_database.';charset=UTF-8', $db_user, $db_pass);
} catch (PDOException $e) {
$agi->conlog("FAIL: Error connecting to the database! " . $e->getMessage());
die();
}
$find_fwd_by_callerid = $pdo->prepare('SELECT destination FROM fwd_table WHERE caller_id=? ');
$caller_id = $agi->request['agi_callerid'];
if($callerid=="unknown" or $callerid=="private" or $callerid==""){
$agi->conlog("Call came in without caller id, I give up");
exit;
}else{
$agi->conlog("Call came in with caller id number $caller_id.");
}
if($find_fwd_by_callerid->execute(array($caller_id)) === false){
$agi->conlog("Database problem searching for forward destination (find_fwd_by_callerid), croaking");
exit;
}
$found_fwds = $find_fwd_by_callerid->fetchAll();
if(count($found_fwds) > 0){
$destination = $found_contacts[0]['destination'];
$agi->set_variable('FWD_TO', $destination);
$agi->conlog("Caller ID matched, setting FWD_TO variable to ''");
}
?>
それから、ダイヤルできるお得なプランでこのように:
AGI(forward_by_callerid.agi)
場合データベースは試合を設定します変数 FWD_TO
といやはや。ください編集ご質問が必要な場合。ってこの統合されたダイヤルプランです。
この記事 ています。この約3ラインのコードは、簡単な質問を追加および削除の転送。
所属していません StackOverflow