常常有些提醒 也不是說鬧鐘或行事曆設好就等著通知來就好了
Thank you for reading this post, don't forget to subscribe!有時候還是得用一些奇怪的方式 腦子有洞如我
就是會大費舟章的搞一個主機 寫個程式 建個排程 丟到LINE Notify
Line還是天天用的嘛
這是傳送的範例 備份一下
function sendLineNotify ( $msgStr = "") {
/**
* [$notifyToken Line notify 設定值]
* @var string
*/
$notifyToken = "{notifyTokenStr這個要去申請喔}" ; // 主機狀態通知
$notifyUrl = 'https://notify-api.line.me/api/notify -H "Authorization: Bearer %s" -d "message=%s"' ;
$msgStr = "\n[Func] ~/sslExtDateNotify.php\n[主機] `XXX.XXX.XXX.XXX`\n" . $msgStr ;
$msgStr = urlencode( $msgStr) ;
$notifyUrlStr = sprintf( $notifyUrl, $notifyToken, $msgStr) ;
exec( "curl {$notifyUrlStr}") ;
}
流程的部份就放在下面
<?php
date_default_timezone_set("Asia/Taipei");
$checkLists = config('node_expect_date') ;
$nowDate = date('Y-m-d');
$nowTime = time() ;
foreach( $checkLists as $nKey => $nodeInfo) {
$expect_str = $nodeInfo['exp_date'] ;
$expect_3day_Time = strtotime( "{$expect_str} -3 day") ;
$expect_5day_Time = strtotime( "{$expect_str} -5 day") ;
$msgArr = [] ;
if ( $nowTime > $expect_5day_Time) {
$msgArr[] = " `{$nKey}` 即將到期" ;
$msgArr[] = "到期日期為: `{$expect_str}`" ;
$msgArr[] = "請儘速更新" ;
sendLineNotify( join ("\n", $msgArr)) ;
} else {
echo "沒事";
}
}