forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.8 KiB
71 lines
1.8 KiB
#!/usr/bin/php -q |
|
<?php |
|
|
|
$ipServidor = $argv[1]; |
|
|
|
$res = ListaCampanha($ipServidor); |
|
|
|
foreach($res as $idLista){ |
|
PausaCampanha($ipServidor, $idLista); |
|
} |
|
|
|
function ListaCampanha($ipServidor) |
|
{ |
|
try { |
|
|
|
$ch = curl_init(); |
|
curl_setopt($ch, CURLOPT_URL, "http://{$ipServidor}/kingdialer/kingAPI.php?action=listcampanhas&login=uditelecom"); |
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
$content = trim(curl_exec($ch)); |
|
curl_close($ch); |
|
$retorno = json_decode($content); |
|
|
|
if(empty($retorno)){ |
|
throw new Exception("Erro - Não há listas cadastradas"); |
|
} |
|
|
|
$ret = objectToArray($retorno); |
|
foreach($ret as $value){ |
|
$listagem[] = $value['id']; |
|
} |
|
return $listagem; |
|
} catch (Exception $ex) { |
|
return $ex->getMessage(); |
|
} |
|
} |
|
|
|
function PausaCampanha($ipServidor, $arListas) |
|
{ |
|
try{ |
|
|
|
$ch = curl_init(); |
|
curl_setopt($ch, CURLOPT_URL, "http://{$ipServidor}/kingdialer/kingAPI.php?action=pausecamp&id_camp={$arListas}&login=uditelecom"); |
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
$content = trim(curl_exec($ch)); |
|
curl_close($ch); |
|
$retorno = json_decode($content); |
|
|
|
if(empty($retorno)){ |
|
throw new Exception("Erro ao realizar o procedimento"); |
|
} |
|
|
|
$ret = objectToArray($retorno); |
|
return $ret['status']; |
|
|
|
} catch (Exception $ex) { |
|
return $ex->getMessage(); |
|
} |
|
} |
|
|
|
function objectToArray($d) { |
|
if (is_object($d)) { |
|
$d = get_object_vars($d); |
|
} |
|
if (is_array($d)) { |
|
return array_map(__FUNCTION__, $d); |
|
} else { |
|
return $d; |
|
} |
|
}
|
|
|