Translate

2022年2月25日 星期五

利用VBA傳送訊息給Line

Token取得可以方式可參考"https://tomyam-yang.blogspot.com/2022/02/google-apps-scripline.html
Sub line_notify()
     '===================================
    'Line訊息
    '===================================
    Dim oXML As Object
   
    Dim Token As String
   
    Dim URL As String
   
    '指定的Line Notify Token
   
    Token = "你的TOKEN"
   
    'Line Notify的傳送訊息網址
       
    Line_Message = "利用VBA傳訊息"
   
    URL = "https://notify-api.line.me/api/notify"

    Set oXML = CreateObject("Microsoft.XMLHTTP")
   
    With oXML
   
        '使用同步傳輸
   
        .Open "POST", URL, 0
   
        '設定傳送封包Header
   
        .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
   
        .setRequestHeader "Authorization", "Bearer " & Token
   
        '執行Ajax傳送
        .send "message=" & Chr(10) & Line_Message
        Debug.Print oXML.responseText
   
    End With
   
    '釋放物件資源
   
    Set oXML = Nothing
End Sub







參考資料:http://forum.twbts.com/thread-22487-1-1.html

利用Google Apps Scrip傳訊息到Line

 參考https://lifewth.com/google-apps-script-line/

依參考資料第一次實作一直出現status":401," message":" Invalid access token

手機重開機一樣失敗、後來重新申請發行權杖儲存後重新執行就可以順利收到訊息。


延伸利用:可以透過簡單單晶片發送訊息給Google Apps Script然後在透過Google Apps Script傳訊息給Line通知使用者。

或者功能強一點的開發版直接跟 LINE Notify連結。