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

沒有留言:

張貼留言