Ejemplo n.º 1
0
                $dtvalidade = date('Y-m-d', strtotime("+" . $dias . " days", strtotime(date("Y-m-d"))));
                $conn->insert(array('dtCad' => date("Y-m-d"), 'idCampanha' => $palavra_chave['idSms'], 'CelularCliente' => $_GET['sender'], 'dtEnvio' => $_GET['when'], 'mensagem' => $_GET['text'], 'status' => 1), "", "sms");
                $mensagem = converteComandosTxt($dados["mensagem"], $campanha, $dtvalidade);
            }
            echo $mensagem;
            //exit("dadafrg ".$msgFim_enviado);
            if ($msgFim_enviado < 1) {
                $usuario = 'montnet';
                $senha = 'Qym56fMu';
                $celulares = explode(";", $_POST['celular']);
                $url = "http://api.infobip.com/api/v3/sendsms/xml";
                $xmlString = "\n\t\t\t\t\t   <SMS>\n\t\t\t\t\t     <authentification>\n\t\t\t\t\t    <username>" . $usuario . "</username>\n\t\t\t\t\t    <password>" . $senha . "</password>\n\t\t\t\t\t     </authentification>\n\t\t\t\t\t     <message>\n\t\t\t\t\t    <sender>" . $dados["campanha"] . "</sender>\n\t\t\t\t\t    <text>" . $mensagem . "</text>\n\t\t\t\t\t    <flash></flash>\n\t\t\t\t\t    <type></type>\n\t\t\t\t\t    <wapurl></wapurl>\n\t\t\t\t\t    <binary></binary>\n\t\t\t\t\t    <datacoding></datacoding>\n\t\t\t\t\t    <esmclass></esmclass>\n\t\t\t\t\t    <srcton></srcton>\n\t\t\t\t\t    <srcnpi></srcnpi>\n\t\t\t\t\t    <destton></destton>\n\t\t\t\t\t    <destnpi></destnpi>\n\t\t\t\t\t    <ValidityPeriod></ValidityPeriod>\n\t\t\t\t\t     </message>\n\t\t\t\t\t     <recipients>\n\t\t\t\t\t     <gsm>" . $_GET['sender'] . "</gsm>\n\t\t\t\t\t    </recipients>\n\t\t\t\t\t   </SMS>  ";
                $fields = "XML=" . urlencode($xmlString);
                //  in this example, POST request was made using PHP's CURL
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
                //  response of the POST request
                $response = curl_exec($ch);
                curl_close($ch);
                $cupons_qtd = $palavra_chave['qtdCupons'] - 1;
                $dados = $conn->update(array("qtdCupons" => $cupons_qtd), "idSms = '" . $palavra_chave['idSms'] . "'", "", "campanha_sms");
                $conn->insert(array('dtCad' => date("Y-m-d"), 'idCampanha' => $palavra_chave['idSms'], 'CelularCliente' => $_GET['sender'], 'dtEnvio' => $_GET['when'], 'mensagem' => $mensagem, 'status' => 3, 'msgFim_enviado' => $msgFim_enviado), "", "sms");
            }
        }
        if (preg_match('/^SAIR/', $txt, $matches, PREG_OFFSET_CAPTURE) || preg_match('/^PARAR/', $txt, $matches, PREG_OFFSET_CAPTURE)) {
            $dados = $conn->delete("CelularCliente = '" . $_GET['sender'] . "'", "", "sms");
        }
    }
}