<meta name="viewport" content="width=device-width, initial-scale=1.0">

<?php
define('LINE_API',"https://notify-api.line.me/api/notify");
 
$token = "tomMXIh9sQFDJH1iP0dwaZxc5pSuzg44AQpnUKjR0FH"; //Line Notify Kamol Group TOMAS 
//$token = "SNeIOvkSmjyJOGu0sroZ84hSmGj5PPY7VLOPXlHASsH"; //Line Notify Kamol Group Technical regular
//$token = "IE8rhhE6SQeM9uuJ64uHbtVhL2DNDsmDefpy5wzBxEV"; //Line Notify Kamol Test Token
//$token = "Mbl2MU5SZAOfHGhwFpYJUEUOHuakN0vPftmR2PMI0dd"; //Line Notify Kamol_II
//$token = "SLmHI7vUiEdh3W9szgSrHCfukMGlBnU6iTzVxJom4zj"; ////Line Notify Group Kamol_II

$str = "Test Line Notify API "; //ข้อความที่ต้องการส่ง สูงสุด 1000 ตัวอักษร

$name=$_POST["name"];
$phpColdWater=$_POST["phpColdWater"];
$strColdWater="Cold Water &nbsp;&nbsp;&nbsp; +" . "$phpColdWater<br />"; 
$lineColdWater="Cold Water   +" . "$phpColdWater\r\n"; 
$phpHotWater=$_POST["phpHotWater"];
$strHotWater="Hot Water &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +" . "$phpHotWater<br />"; 
$lineHotWater="Hot Water     +" . "$phpHotWater\r\n"; 
$phpHotTea=$_POST["phpHotTea"];
$strHotTea="Hot Tea  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +" . "$phpHotTea<br />"; 
$lineHotTea="Hot Tea         +" . "$phpHotTea\r\n"; 
$phpHotCoffee=$_POST["phpHotCoffee"];
$strHotCoffee="Hot Coffee &nbsp;&nbsp;&nbsp;&nbsp; +" . "$phpHotCoffee<br />"; 
$lineHotCoffee="Hot Coffee    +" . "$phpHotCoffee\r\n";
$strMessage="<br />$name<br />";
$str="\r\n$name\r\n";
  if ($phpColdWater > "0") {
    $strMessage = $strMessage . $strColdWater;
    $str = $str . $lineColdWater;
  }
  if ($phpHotWater > "0") {
    $strMessage = $strMessage . $strHotWater;
    $str = $str . $lineHotWater;
  }
  if ($phpHotTea > "0") {
    $strMessage = $strMessage . $strHotTea;
    $str = $str . $lineHotTea;
  }
  if ($phpHotCoffee > "0") {
    $strMessage = $strMessage . $strHotCoffee;
    $str = $str . $lineHotCoffee;
  }
  //echo "$strMessage";
if ($phpColdWater > "0" || $phpHotWater > "0" || $phpHotTea > "0" || $phpHotCoffee > "0") {
$res = notify_message($str,$token);
print_r($res);
print_r($strMessage);
}
else{
  print_r("Please press the plus drink button before ordering a drink.");
}

function notify_message($message,$token){
 $queryData = array('message' => $message);
 $queryData = http_build_query($queryData,'','&');
 $headerOptions = array( 
         'http'=>array(
            'method'=>'POST',
            'header'=> "Content-Type: application/x-www-form-urlencoded\r\n"
                      ."Authorization: Bearer ".$token."\r\n"
                      ."Content-Length: ".strlen($queryData)."\r\n",
            'content' => $queryData
         ),
 );
 $context = stream_context_create($headerOptions);
 $result = file_get_contents(LINE_API,FALSE,$context);
 $res = json_decode($result);
 return $res;
}
?>