1C: Enterprise 8.2 (8.2.17.143)
“Trade and Customer Relationship Management” (CRM + UT)
About 10,000 counterparties.
DBMS MS SQL
IIS Web Server
PBX Askozia CFE 2.1:
Asterisk 1.8.4.4
PHP 4.4.9
AGI phpagi.php, v 2.14
// Asterisk // (dbFamily, dbKey, dbValue) = ActionID = (); = ""; .DBPut(dbFamily, dbKey, dbValue, ActionID, ) ; ; (" "); ; (" "); ; ; //
// dbFamily - “cidname” // “ ” // dbKey - , , // dbValue - ("cidname", “74952293042”, “OOO MIKO”);
IP_WEB_SERVER_1C/TestComponenta/ws/1C_MIKO_identify_number.1cws?wsdl
identify(Number) = ""; (Number); // , // (Number) = "OOO MIKO " + Number+ ""; ;
curl --header <> -d '<XML >' < >
curl --header "Content-Type: text/xml; charset=utf-8" -d '<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><m:identify xmlns:m="http://wiki.miko.ru/doc:1cajam:identifynumber"><m:Number>74952293042</m:Number></m:identify></soap:Body></soap:Envelope>' IP_WEB_SERVER_1C/TestComponenta/ws/1C_MIKO_identify_number.1cws
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header/> <soap:Body> <m:identifyResponse xmlns:m="http://wiki.miko.ru/doc:1cajam:identifynumber"> <m:return xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">OOO MIKO 74952293042</m:return> </m:identifyResponse> </soap:Body> </soap:Envelope>
#!/usr/bin/php -f <?php require('phpagi.php'); // // AGI phpagi.php,v 2.14 get_variable $start_found = false; $end_found = false; $ret_value = ''; function tagStart($parse, $name, $attribs){ global $start_found; if($name == 'M:RETURN'){ // echo($name); $start_found = true; } } function tagEnd($parser, $name){ global $start_found; global $end_found; if($name == 'M:RETURN'){ $end_found = true; } } function dataGet($parser, $data){ global $start_found; global $ret_value; global $end_found; if($start_found&&!$end_found){ $ret_value = ''.$data; } } function parse_response($response){ // xml $xml_parse = xml_parser_create(); xml_set_element_handler($xml_parse, 'tagStart', 'tagEnd'); xml_set_character_data_handler ($xml_parse, 'dataGet'); xml_parse($xml_parse, $response); // , xml_parser_free($xml_parse); } function GetVarChannnel($agi, $_varName){ $v = $agi->get_variable($_varName); if(!$v['result'] == 0){ $agi->verbose($_varName.' ---> '.$v['data'], 10); return $v['data']; } else{ $agi->verbose($_varName.' not set', 10); return ""; } } // GetVarChannnel($_agi, $_varName) // agi, phpagi.php $agi = new AGI(); // , $path = '/TestComponenta/ws/1C_MIKO_identify_number.1cws'; $server = 'IP_WEB_SERVER_1C'; $port = 80; $number = GetVarChannnel($agi, "CALLERID(num)");; $user_1c= "1C_USERNAME"; $pass_1c= '1C_PASSWORD'; $auth = base64_encode($user_1c.':'.$pass_1c); $crlf = "\r\n"; // - SOAP $xmlDocument = ( '<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <m:identify xmlns:m="http://wiki.miko.ru/doc:1cajam:identifynumber"> <m:Number>'.$number.'</m:Number> </m:identify> </soap:Body> </soap:Envelope>'); $contentLength = strlen($xmlDocument); // if (($http_soket = @fsockopen($server, $port, $errno, $errstr,1.5)) == false) return; $query = "POST $path HTTP/1.1" .$crlf; $query .= "Host: $server" .$crlf; $query .= "Content-Type: text/xml; charset=utf-8" .$crlf; $query .= "Authorization: Basic $auth" .$crlf; $query .= "Content-Length: $contentLength" .$crlf; $query .= $crlf; $query .= $xmlDocument; // 1 stream_set_timeout($http_soket, 1, 0); // fputs($http_soket, $query); $result = ''; // while ($line = fgets($http_soket)) $result .= $line; // $result = substr($result, strpos($result, $crlf.$crlf) + 4); fclose($http_soket); // parse_response($result); if($ret_value != ''){ $agi->set_variable('CALLERID(name)', $ret_value); // 1 , CDR } ?>​
# dialplan show 1334444@internal [ Context 'internal' created by 'pbx_config' ] '1334444' => 1. NoOp(internal calling application: AGI_App_CallerID) [pbx_config] 2. Set(CDR(InternalCalleridNum)=1334444) [pbx_config] 3. Goto(DIALPLAN-APPLICATION-176239923050fac4c5678b9,${EXTEN},1) [pbx_config] -= 1 extension (3 priorities) in 1 context. =-
# dialplan show DIALPLAN-APPLICATION-176239923050fac4c5678b9 [ Context 'DIALPLAN-APPLICATION-176239923050fac4c5678b9' created by 'pbx_config' ] 'h' => 1. Hangup() 's' => 1. AGI(DIALPLAN-APPLICATION-176239923050fac4c5678b9.php) 2. Hangup() '_[0-9a-zA-Z*#]!' =>1. AGI(DIALPLAN-APPLICATION-176239923050fac4c5678b9.php) 2. Hangup() -= 3 extensions (5 priorities) in 1 context. =-
Source: https://habr.com/ru/post/166935/
All Articles