-
-
Save GiancarloJSantos/df0ef7b69ced90bae2fc527dc22ecbd4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-> GRID - onRecord | |
-------------------------------------------------------------------- | |
{wpp} = "<img class='cm_wpp' data-phone='".{telefone}."' data-nome='".{nome}."' data-id='".{id}."' src='/scriptcase9/app/BootstrapTour/_lib/img/grp__NM__ico__NM__if_WhatsApp_1298775.png' border='0'>"; | |
-------------------------------------------------------------------- | |
-> GRID - onScriptInit | |
-------------------------------------------------------------------- | |
sc_include_lib("Jquery"); | |
?> | |
<script> | |
window.onload = function(e){ | |
$(".cm_wpp").on("click", function() { | |
var phone = $(this).attr("data-phone"); | |
var nome = $(this).attr("data-nome"); | |
var id = $(this).attr("data-id"); | |
var url = 'https://eu6.chat-api.com/instance4371/message?token=i5slswgjo427xhgs'; | |
var body = 'Olá '+nome+', tudo bem?\nVocê está recebendo uma mensagem devido à sua solicitação de teste da API do WhatsApp.'; | |
var data = { | |
phone: phone, | |
body: body | |
}; | |
$.ajax(url, { | |
data : JSON.stringify(data), | |
contentType : 'application/json', | |
type : 'POST' | |
}); | |
}); | |
} | |
</script> | |
<?php | |
-------------------------------------------------------------------- | |
-> FORM - beforeInsert | |
-------------------------------------------------------------------- | |
$phone = {telefone}; | |
$phone = str_replace(" ", "", $phone); | |
$phone = str_replace("+", "", $phone); | |
$phone = str_replace(".", "", $phone); | |
{telefone} = $phone; | |
-------------------------------------------------------------------- | |
-> FORM - afterInsert | |
$var_phone = {telefone}; | |
$var_nome = {nome}; | |
$var_conteudo = "Olá ".$var_nome.", tudo bem? Você está recebendo uma mensagem devido à sua solicitação de teste da API do WhatsApp. | |
Att. Camila Moreira"; | |
$data = [ | |
'phone' => $var_phone, | |
'body' => $var_conteudo, | |
]; | |
$json = json_encode($data); | |
$url = 'https://eu6.chat-api.com/instance4371/message?token=i5slswgjo427xhgs'; | |
$options = stream_context_create(['http' => [ | |
'method' => 'POST', | |
'header' => 'Content-type: application/json', | |
'content' => $json | |
] | |
]); | |
$result = file_get_contents($url, false, $options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment