การประยุกต์ใช้ Line notify ในกรณี user พิมพ์มาไม่ตรงกับ intent ใดๆ ใน Abdul





test

https://localhost/noti.php?token=line_notify_token&user_id=U12fddaf8f57c6685b2b7120e23328e71&img=https://localshost/img/verygood.png&message=test





//////////////// php ///////////////

<?php
$user_id = $_REQUEST['user_id'];
$token = $_REQUEST['token'];
$message = $_REQUEST['message'];
$pic = $_REQUEST['img'];
$text = 'From '.$user_id.' '.$message;

echo "___SILENT___";

$chOne = curl_init();
curl_setopt( $chOne, CURLOPT_URL, "https://notify-api.line.me/api/notify");
// SSL USE
curl_setopt( $chOne, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt( $chOne, CURLOPT_SSL_VERIFYPEER, 0);
//POST
curl_setopt( $chOne, CURLOPT_POST, 1);
// Message
curl_setopt( $chOne, CURLOPT_POSTFIELDS, $message);
//ถ้าต้องการใส่รุป ให้ใส่ 2 parameter imageThumbnail และimageFullsize
curl_setopt( $chOne, CURLOPT_POSTFIELDS, "message=$text&imageThumbnail=$pic&imageFullsize=$pic");
// follow redirects
curl_setopt( $chOne, CURLOPT_FOLLOWLOCATION, 1);
//ADD header array
$headers = array( 'Content-type: application/x-www-form-urlencoded', 'Authorization: Bearer '.$token, );
curl_setopt($chOne, CURLOPT_HTTPHEADER, $headers);
//RETURN
curl_setopt( $chOne, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec( $chOne );
//Check error
if(curl_error($chOne)) {
echo 'error:' . curl_error($chOne);
}
else {
$result_ = json_decode($result, true);
//echo "status : ".$result_['status'];
//echo "message : ". $result_['message'];
}
//Close connect
curl_close( $chOne );
?>


//////////////////////////////

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

แจ้งเตือนเข้าไลน์กลุ่ม ผ่าน Line notify เมื่อมีคน login เข้า server ของเราผ่าน SSH (linux) หรือ remote desktop เข้ามา (windows server)

การทำ cloud iot ด้วย thingsboard ไว้ใช้เองครับ

การประยุกต์ใช้ line notify ในการแจ้งปัญหาการใช้งาน สำหรับ php