Code สำหรับแจ้งเตือน ใช้แทน Line notify


0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

03 มี.ค. 68 , 16:21:24
อ่าน 433 ครั้ง

chai

Code สำหรับแจ้งเตือน ใช้แทน Line notify
« เมื่อ: 03 มี.ค. 68 , 16:21:24 »
31 มีนาคม นี้ ทางไลน์จะยกเลิก Line notify แบบที่เราใช้ฟรีกัน เป็นแบบ Messaging API เผื่อมีใครสนใจจะใช้ App Telegram แทน Line ครับ
VBA Code (ใช้ Deepseek generate ให้ครับ) ผมลองเอามาทดสอบแล้วใช้งานได้ปกติ และฟรีด้วยครับ

Sub SendTelegramMessage()
    Dim BotToken As String
    Dim ChatID As String
    Dim MessageText As String
    Dim ApiUrl As String
    Dim JsonPayload As String
    Dim HttpRequest As Object

    ' Replace with your bot token and chat ID
    BotToken = "YOUR_BOT_TOKEN"
    ChatID = "YOUR_CHAT_ID"
    MessageText = "Hello from Microsoft Access!"

    ' Construct the API URL
    ApiUrl = "https://api.telegram.org/bot" & BotToken & "/sendMessage"

    ' Create the JSON payload
    JsonPayload = "{""chat_id"": """ & ChatID & """, ""text"": """ & MessageText & """}"

    ' Create the HTTP request object
    Set HttpRequest = CreateObject("MSXML2.XMLHTTP")

    ' Send the POST request
    With HttpRequest
        .Open "POST", ApiUrl, False
        .setRequestHeader "Content-Type", "application/json"
        .send JsonPayload
    End With

    ' Check the response
    If HttpRequest.Status = 200 Then
        MsgBox "Message sent successfully!", vbInformation
    Else
        MsgBox "Failed to send message. Status: " & HttpRequest.Status & ", Response: " & HttpRequest.responseText, vbCritical
    End If

    ' Clean up
    Set HttpRequest = Nothing
End Sub

 
โพสต์นี้ได้รับคำขอบคุณจาก: PookPuy, TTT, aek, Racha01


บอร์ดเรียนรู้ Access สำหรับคนไทย



There are no comments for this topic. Do you want to be the first?
 

Sitemap 1 2 3 4 5