Created
May 27, 2022 23:20
-
-
Save mateusfmello/118fe49f817ec30eab166f35829c86f7 to your computer and use it in GitHub Desktop.
Modelo de arquivo final gerado pelo MK Auth para fazer requisições de envio de mensagens, é necessário que o usuário informe apenas dois dados, URL do serivdor e Token de autorização da API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env /opt/mk-auth/hhvm/5-4-45/bin/php | |
<?php | |
# Sistema MK-AUTH - Padrão MK Auth | |
include('/opt/mk-auth/include/configure.php'); | |
include('/opt/mk-auth/include/conexao.php'); | |
# inicio - Dados dinâmicos | |
$urlServidor = [ URL SERVIDOR ]; | |
$tokenApi = [ TOKEN API ]; | |
$dados = array( | |
'mensagem' => [ MENSAGEM ], | |
'telefone' => [ TELEFONE ] | |
); | |
# fim - Dados dinâmicos | |
$psax = substr_count(shell_exec(' ps ax | grep ' . __FILE__), PHP_EOL); | |
if ($psax > 3) die(); | |
sleep([ TEMPO DE DELAY ]); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $urlServidor); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); # Recuperando a resposta do servidor | |
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 6); # Setando timeout | |
curl_setopt($curl, CURLOPT_TIMEOUT, 60); # Setando timeout | |
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); # Segue os cabeçalhos "Location" retornados na resposta da requisição | |
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($dados)); # Setando os dados na requisição | |
curl_setopt($curl, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', # Setando o tipo do conteúdo para JSON | |
'Authorization: ' . $tokenApi # Setando o token de autorização da API | |
)); | |
curl_exec($curl); | |
curl_close($curl); | |
@unlink(__FILE__); | |
# incremento [ TEMPO DE DELAY ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment