123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- $unit_code = $argv[1];
- $api_key = $argv[2];
- processUnit($unit_code);
- function processUnit($unit_code) {
- global $api_key;
- static $unitId = 1;
- static $appointmentId = 1;
- if (empty($unit_code)) {
- return;
- }
- $unit = json_decode(file_get_contents('https://voip.mephi.ru/units/'.$unit_code.'.json?renderFilter=unit_selected&apiKey='.$api_key.'&effectiveSecurityLevel=1024'), 1)['unit_selected'];
- $phones = json_decode(file_get_contents('https://voip.mephi.ru/phones.json?phone.PinnedToUnitKey='.$unit_code.'&renderFilter=phones&apiKey='.$api_key.'&effectiveSecurityLevel=1024'), 1)['phones'];
- foreach ($phones as $phone) {
- if (empty($phone['Lines'])) {
- continue;
- }
- foreach ($phone['Lines'] as $line) {
- print "INSERT INTO `phone_configs` SET `phone_mac`='".$phone['Mac']."', `extension`='".$line['Extension']."', created_at=NOW(), updated_at=NOW();\n";
- }
- }
- if (isset($unit['Children'])) {
- foreach ($unit['Children'] as $child) {
- processUnit(str_replace($child['CodeStr'], " ", ""));
- }
- }
- }
- ?>
|