ก่อนอื่น ให้ท่าน เข้าแอพ LINE คลิกเลือกค้นหา
พิมพ์ LINE Notify เมื่อพบแล้วให้ทำการ Add friend

1.) สร้างแบบฟอร์ม สำหรับกรอกข้อมูล เพื่อส่งข้อความจากหน้าเว็บไปยัง Line-Notify ตั้งชื่อไฟล์เป็น line-notify.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Us via Line-Notify</title>
<meta name="language" content="TH" >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<center>
<form name="line-notify" action="line-notify-api.php" method="post">
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="2" align="center"><img src="images/linebutton/linebutton_20x20_en.png" border="0"></td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td colspan="2" align="center"><font color="#0000ff"><b>กรุณากรอกรายละเอียด</b></font></td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>ชื่อ:</td><td><input class="textInput" type="text" name="name" size="25" required> *</td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>อีเมล์:</td><td><input class="textInput" type="text" name="email" size="25" required> *</td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>โทรศัพท์:</td><td><input class="textInput" type="text" name="phone" size="25" required> (Option)</td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>LINE ID:</td><td><input class="textInput" type="text" name="lineid" size="25" required> (Option)</td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>ข้อความ:</td><td><textarea rows='5' name='mesg' cols='50' style='border: 1 solid #99FF00'>ความยาวไม่เกิน 600 ตัวอักษร</textarea>
<tr><td colspan="2" height="10"></td></tr>
<tr><td colspan=2 align="center"><input type="submit" name="submit" value=" ส่งข้อความ "></td></tr>
<tr><td colspan="2" height="10"></td></tr>
</table>
</form>
</center>
</body>
</html>
ตัวอย่างการแสดงผลหน้า line-notify.html

2.) สร้าง script php เพื่อรับค่า input จาก line-notify.html เพื่อส่งข้อมูลไป line-notify api โดยตั้งชื่อไฟล์เป็น line-notify-api.php
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$lineid = $_POST['lineid'];
$mesg = $_POST['mesg'];
$message = $mesg."\n".'จาก: '.$name."\n".'อีเมล์: '.$email."\n".'Phone: '.$phone."\n".'Line ID: '.$lineid;
if($name<>"" || $email <> "" || $mesg <> "") {
sendlinemesg();
header('Content-Type: text/html; charset=utf-8');
$res = notify_message($message);
echo "<center>l;ส่งข้อความเรียบร้อยแล้ว</center>";
} else {
echo "<center>Error: กรุณากรอกข้อมูลให้ครบถ้วน</center>";
}
function sendlinemesg() {
define('LINE_API',"https://notify-api.line.me/api/notify");
define('LINE_TOKEN','ใส่ TOKEN ของท่าน');
function notify_message($message){
$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 ".LINE_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;
}
}
?>
3.) การออก LINE_TOKEN เข้าไปที่เว็บไซต์
https://notify-bot.line.me/th/

4.) Login โดยใช้ Username & Password LINE (Account ที่ท่านต้องการรับข้อมูล)

5.) คลิกเลือกเมนู หน้าของฉัน

6.) คลิกปุ่ม ออก Token

7.) กรอกชื่อ Token และ คลิกเลือก รับการแจ้งเตือนแบบตัวต่อตัว จากนั้นคลิกปุ่ม ออก Token
ท่านจะได้รับข้อความแจ้งเตือนใน LINE ดังนี้

8.) คลิกปุ่ม คัดลอก แล้วนำ Token ที่ได้ไปใส่ในไฟล์ line-notify-api.php บรรทัดที่ 27 ตรง define('LINE_TOKEN','
ใส่ TOKEN ของท่าน');

9.) เมื่อทำการ คัดลอก Token เรียบร้อยแล้ว ให้คลิกปุ่ม ปิด จะพบหน้าจอดังนี้

10.) ทำการทดสอบ โดยการเปิดไฟล์ line-notify.html กรอกรายละเอียด และ คลิกปุ่ม ส่งข้อความ
หมายเหตุ: Script line-notify-api.php ไม่สามารถ Run/ทดสบ บน Localhost ต้อง Run/ทดสบ บนโฮสต์เท่านั้น
ท่านจะได้รับข้อความแจ้งเตือนใน LINE ดังนี้

คลิกเพื่อ Download ไฟล์ตัวอย่าง (เพียงแก้ไข LINE_TOKEN ก็สามารถใช้งานได้เลย) -->
line-notify-contact-us.rar (Update: 16/04/2017)
หรือ Save เก็บไว้ใน Google Drive ของคุณ
แตกไฟล์ออก แล้ว Upload ขึ้นไปไว้บน Server