Script php ส่งภาพเข้า Line โดยใช้ notify และส่ง 1 Token
<?php
// Replace 'YOUR_ACCESS_TOKEN' with your actual Line Notify access token.
$accessToken = 'YOUR_ACCESS_TOKEN';
// The picture URL you want to send.
$pictureUrl = 'URL_OF_YOUR_PICTURE';
// API URL for Line Notify.
$url = 'https://notify-api.line.me/api/notify';
// Set headers for the request.
$headers = array(
'Authorization: Bearer ' . $accessToken,
);
// Prepare the POST data.
$data = array(
'message' => 'This is a Line Notify test message with a picture.',
'imageThumbnail' => $pictureUrl,
'imageFullsize' => $pictureUrl,
);
// Initialize cURL session.
$ch = curl_init();
// Set cURL options.
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute cURL session and get the response.
$response = curl_exec($ch);
// Close cURL session.
curl_close($ch);
// Process the response.
if ($response === false) {
echo 'Error sending Line Notify message: ' . curl_error($ch);
} else {
echo 'Message sent successfully!';
}