Skip to content

Instantly share code, notes, and snippets.

@f2sc
Created June 1, 2019 22:31
Show Gist options
  • Save f2sc/4a778e26990272228b8a116e7378374c to your computer and use it in GitHub Desktop.
Save f2sc/4a778e26990272228b8a116e7378374c to your computer and use it in GitHub Desktop.
Enviar whatsapp desde web
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<title>Envío de notificación con Whatsapp</title>
</head>
<body>
<div class="container">
<div class="row">
<?php
if (isset($_REQUEST['mensaje']) && isset($_REQUEST['telefono'])){
$urlWhats = 'https://wa.me/';
$urlFinal = $urlWhats . $_REQUEST['telefono'] . '?text=' . $_REQUEST['mensaje'];
?>
<a class="btn btn-primary btn-md" href="<?php echo $urlFinal ?>" target="_blank">Enviar: <?php echo $urlFinal ?></a>
<?php
}else{
?>
<!-- https://wa.me/5211234567890?text=Me%20gustaría%20saber%20el%20precio%20del%20coche -->
<form id="enviarMensaje" action="whatsapp.php" method="get">
<label for="telefono">Teléfono</label>
<input type="tel" name="telefono" id="telefono" value="34" required>
<label for="mensaje">Mensaje</label>
<input type="text" name="mensaje" id="mensaje" value="test nº: " required>
<input type="submit" value="Enviar">
</form>
<?php
}
?>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment