'text',
'text' => 'ทดสอบระบบ'."\n"."User Fullname: ". $fullname ."\n"."User Email: " . $email ."\n"."Payment:".$payment."บาท"
);
// $messages = "User Email: " . $email ."\n";
// $messages = "User Fullname: ". $fullname ."\n";
$post = json_encode(array(
'to' => array($userId),
'messages' => array($messages),
));
$url = 'https://api.line.me/v2/bot/message/multicast';
$headers = array('Content-Type: application/json', 'Authorization: Bearer '.$access_token);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
if ($result){
$_SESSION['success'] = "ส่งข้อความแล้ว";
header("location: index.php");
}else {
$_SESSION['error'] = "ส่งข้อความไม่ได้";
header("location: index.php");
}
if(curl_error($ch)){
echo 'error:'.curl_error($ch);
} else {
$result_ = json_decode($result, true);
}
}
?>