网站 HTML 上的 Twilio Whatsapp 联系表

时间:2021-05-14 00:50:37

标签: php html api twilio whatsapp

您好,我正在尝试制作将信息发送到 whatsapp 的 html 联系表单,但我没有在我的 whatsapp 上收到消息,我将在此处发布代码……以及在我在 Twilio 上打开 whatsapp 沙箱后的另一个问题,我需要在 Twilio WebHook 上再放一个链接??

<?php 
 
// Update the path below to your autoload.php, 
// see https://getcomposer.org/doc/01-basic-usage.md 
require_once '/twilio-php-main/src/Twilio/autoload.php';  
 
use Twilio\Rest\Client; 
$fullname = $_POST['fullname'];
$phone    = $_POST['phone'];
$message  = $_POST['message'];

$sid      = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token    = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$twilio   = new Client($sid, $token); 
 
$message = $twilio->messages 
                  ->create("whatsapp:+972506038686", // to 
                           array( 
                               "from" => "whatsapp:+14155238886",       
                               "body" => "New clinet from website.\n Name: $name \nPhone: $phone \nMessage: $message" 
                           ) 
                  ); 
 
print($message->sid);
?>
<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
  <meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<body>

  <div class="container">
    <form method="post" action="main.php">
  
      <label for="fullname">Full Name</label>
      <input type="text" id="fullname" name="fullname" placeholder="Your full name..">
  
      <label for="phone">Phone Number</label>
      <input type="text" id="phone" name="phone" placeholder="Your phone number..">
  
      <label for="message">Message</label>
      <textarea id="message" name="message" placeholder="Write something.." style="height:100px"></textarea>
  
      <input type="submit" value="Submit">
  
    </form>
  </div>
  
</body>
</html>
<style>
body {font-family: Arial, Helvetica, sans-serif;}
*{box-sizing: border-box;}input[type=text], select, textarea {width: 100%;padding: 12px;border: 1px solid #ccc;border-radius: 4px;box-sizing: border-box;margin-top: 6px;margin-bottom: 16px;resize: vertical;}input[type=submit] { background-color: #bd1321;color: white;padding: 12px 20px;border: none;border-radius: 4px;cursor: pointer;}input[type=submit]:hover {background-color: #9c0814;}.container {border-radius: 5px;background-color: #f2f2f2;padding: 20px;}
</style>

0 个答案:

没有答案