Skip to content

Instantly share code, notes, and snippets.

@srsad
Last active June 26, 2018 08:21
Show Gist options
  • Save srsad/028c579ec3187ff42c7783363b0a69cb to your computer and use it in GitHub Desktop.
Save srsad/028c579ec3187ff42c7783363b0a69cb to your computer and use it in GitHub Desktop.
<?php
if ($_POST['fphone']) {
$api_key = '37iss1fvfbr8r53i4v3a998cawq9je5c';
$api_salt = 'cevv51gb2y9ku2soom468pqvc7ulcpof';
$number = preg_replace('/[^0-9]/', '', $_POST['fphone']);
if(iconv_strlen($number) === 10){
$number = 7 . $number;
}elseif(iconv_strlen($number) === 11){
$number = preg_replace('/^./', 7, $number);
}
// звонок группе
$url = 'https://app.mango-office.ru/vpbx/commands/callback_group';
$data = array(
'command_id' => 'cbk1',
'from' => '100', // внутренний номер группы
'to' => $number, // кому звонить (номер клиента)
'line_number' => '78126144455' // номер линии (АОН)
);
$json = json_encode($data);
$sign = hash('sha256', $api_key . $json . $api_salt);
$postdata = array(
'vpbx_api_key' => $api_key,
'sign' => $sign,
'json' => $json
);
$post = http_build_query($postdata);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
$modx->log(1, 'mango_log: ' . $response);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment