【问题标题】:How can I send message to telegram using API and C#? [closed]如何使用 API 和 C# 向电报发送消息? [关闭]
【发布时间】:2016-04-30 06:56:27
【问题描述】:

我有频道,我想使用 C# 和电报 API 向该频道发送自动消息。

我该怎么办?

【问题讨论】:

    标签: c# telegram


    【解决方案1】:

    首先创建一个机器人并将其作为管理员添加到您的频道

    帮助:

    Adding Bot as administrator to channel

    Creating Bot

    然后使用以下代码向您的群组发送消息

    WebRequest req = WebRequest.Create("https://api.telegram.org/bot" + yourToken + "/sendMessage?chat_id=" + channel_id + "&text=" + message);
    req.UseDefaultCredentials = true;
    
    var result = req.GetResponse();
    req.Abort();
    

    yourToken 是您的机器人令牌,channel_id 是您的频道 ID,message 是您要发送到频道的字符串

    【讨论】:

    • WebRequest 在 System.net
    • 如何找到Token
    猜你喜欢
    • 2015-07-31
    • 2022-08-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 2016-06-02
    • 2021-06-11
    • 1970-01-01
    • 2020-11-26
    相关资源
    最近更新 更多