【问题标题】:C# Send message to channel telegram from botC# 从机器人向频道电报发送消息
【发布时间】:2020-08-25 20:24:20
【问题描述】:

我使用一些代码制作频道帖子“Hello Word”

string urlString = "https://api.telegram.org/bot{0}/sendMessage?chat_id={1}&text={2}";
                string apiToken = "1143035780:AAEG5vU5j2_Nc5rLK8B2ORp3ItpYoNicokU";
                string chatId = "@kekcheburekks";
                string text = "Hello world!";
                urlString = String.Format(urlString, apiToken, chatId, text);
                WebRequest request = WebRequest.Create(urlString);
                Stream rs = request.GetResponse().GetResponseStream();
                StreamReader reader = new StreamReader(rs);
                string line = "";
                StringBuilder sb = new StringBuilder();
                while (line != null)
                {
                    line = reader.ReadLine();
                    if (line != null)
                        sb.Append(line);
                }
                string response = sb.ToString();

但我遇到了异常 - 找不到 chatId!

【问题讨论】:

标签: c# telegram telegram-bot


【解决方案1】:

我认为问题在于当您传递@ 符号时,请尝试不使用它,如下所示:

string chatId = "kekcheburekks";

不用像这样使用@

string chatId = "@kekcheburekks";   

【讨论】:

    猜你喜欢
    • 2016-05-03
    • 2017-03-19
    • 2017-05-11
    • 1970-01-01
    • 1970-01-01
    • 2017-09-01
    • 2020-08-25
    • 2020-02-05
    • 2022-01-27
    相关资源
    最近更新 更多