Skip to content

Instantly share code, notes, and snippets.

@acidiney
Last active April 17, 2020 19:05
Show Gist options
  • Save acidiney/9b14ab8313b9c0bff32fdfb72835fecc to your computer and use it in GitHub Desktop.
Save acidiney/9b14ab8313b9c0bff32fdfb72835fecc to your computer and use it in GitHub Desktop.
public function sendMessage(Array $destinies, String $message, $hasSpecialCharacter = false) {
$data = [
"ApiKey" => "ApiKey",
"Mensagem" => $message,
"Destino" => $destinies,
"CEspecial" => $hasSpecialCharacter
];
$header = [
'http' => [
'method' => 'POST',
'header' => [
'Content-Type: application/json',
"Content-Length: " . strlen(json_encode($data)) . "\r\n"
],
'content' => json_encode($data)
],
];
$context = stream_context_create($header);
$response = file_get_contents(
"https://api.wesender.co.ao/envio/apikey",
false,
$context
);
$responseDecode = json_decode($response, true);
$res = [
"Success" => false,
"Message" => 'Não foi possivel enviar mensagens'
];
if ($responseDecode['Exito']) {
$res = [
"Success" => true,
"Message" => $responseDecode['Message']
];
}
return $res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment