A2Billing 的 Callback 除了 CID Callback, Web Callback 以外,還有一種透過 API 方式的 Callback,可應用於 3rd party 軟體的整合。
系統需求
yum install php-soap pear install -f -o SOAP
cd /usr/src/a2billing/ cp -r webservice /var/www/html/a2b_api cd /var/www/html/a2b_api
網頁檔架構:
a2b_api/SOAP/
預設的 PHP 檔是關閉 API 的,編輯 test-callback-server.php,將它打開:
編輯 SOAP/test-callback-server.php
修改 SOAP Server 的 URL
$endpoint = 'http://this.is.server.ip/a2b_api/SOAP/soap-callback-server.php';
將上下的註解符號刪除
... /* <== 刪除 echo "<hr>############# Request CallBack ############# <br/><hr/>"; $method = 'Request'; $params = array('security_key' => md5($security_key), 'pn_calledparty' => '0034650784355', 'pn_destination' => '00341111122444', 'callerid' => '0034650555555', 'callback_time' => '', 'uniqueid' => '', 'accountnumber' => '6098593343'); $ans = $callback -> call($method, $params); print_r($ans); $insert_id_callback = $ans[0]; */ <== 刪除 ...
編輯 SOAP/test-callback-server.php
... $params = array('security_key' => md5($security_key), 'pn_calledparty' => '0034650784355', 'pn_destination' => '00341111122444', 'callerid' => '0034650555555', 'callback_time' => '', 'uniqueid' => '', 'accountnumber' => '6098593343'); ...
Tips:
使用另一部電腦,開啟瀏覽器輸入 http://this.is.server.ip/a2b_api/SOA...ack-server.php,若一切正常,系統會依照參數啟動 callback,網頁會輸出訊息如下:
############# Request CallBack ############# Array ( [0] => 103 [1] => result=Success [2] => Success - Callback request has been accepted ) ############# Check Status ############# Array ( [0] => rp3t9-1352346433 [1] => result=PENDING [2] => - Callback request found SELECT status, uniqueid FROM cc_callback_spool WHERE id='103' )
Tips: