Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么我在电报机器人中得到错误的文件标识符/HTTP URL指定错误?_C#_Telegram Bot - Fatal编程技术网

C# 为什么我在电报机器人中得到错误的文件标识符/HTTP URL指定错误?

C# 为什么我在电报机器人中得到错误的文件标识符/HTTP URL指定错误?,c#,telegram-bot,C#,Telegram Bot,我是电报机器人的新手,尝试用以下代码向用户发送照片: await Bot.SendPhotoAsync(update.Message.Chat.Id, "http://182.126.201.42/" + "iisstart" + ".png"); 但当我尝试运行该代码时,会出现以下错误: Bad Request: Wrong file identifier/HTTP URL specified 我如何解决这个问题?谢谢。根据您可以发送的照片: await Bot.SendChatAct

我是电报机器人的新手,尝试用以下代码向用户发送照片:

await Bot.SendPhotoAsync(update.Message.Chat.Id, "http://182.126.201.42/" + "iisstart" + ".png");

但当我尝试运行该代码时,会出现以下错误:

Bad Request: Wrong file identifier/HTTP URL specified

我如何解决这个问题?谢谢。

根据您可以发送的照片:

await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.UploadPhoto);

            const string file = @"<FilePath>";

            var fileName = file.Split('\\').Last();

            using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var fts = new FileToSend(fileName, fileStream);

                await Bot.SendPhotoAsync(message.Chat.Id, fts, "Nice Picture");
            }
wait Bot.SendChatActionAsync(message.Chat.Id,ChatAction.UploadPhoto);
常量字符串文件=@“”;
var fileName=file.Split('\\').Last();
使用(var fileStream=newfilestream(file,FileMode.Open,FileAccess.Read,FileShare.Read))
{
var fts=新文件发送(文件名,文件流);
等待Bot.SendPhotoAsync(message.Chat.Id,fts,“漂亮的图片”);
}

文档:

问题可能源于以下问题:

  • 电报不允许使用图像文件扩展名
  • 文件大小大于电报允许的大小

你可以从前一个开始

您确定您的URL有效/可以通过网络电报访问吗?我自己无法访问它是的,我可以访问,我弄错了up地址,所以您在代码中使用的给出错误消息的url实际上是?@JemarJones这是我的code@JemarJones发生了什么事?