การประยุกต์ใช้ 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 );
?>
ความคิดเห็น
แสดงความคิดเห็น