如何使用 API 和 C# 将消息发送到电报?

How can I send message to telegram using API and C#?

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

我该怎么办?

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

帮助:

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 是您要发送到频道的字符串