我正在开发一个名为InlineQuery的Telegram bot API的新功能的机器人,我在C#中实现所有类型,现在可以将从Telegram返回的查询到我的机器人,当我尝试回答我在Json下面发布的查询时电报answerInlineQuery方法,但我收到此错误:
"错误请求:无法解析json编码的内联查询结果:[错误]:无法解析数字"
{"inline_query_id":"515050766530700016","results":[{"type":"photo","photo_url":"http://weknowyourdreams.com/images/car/car-05.jpg","photo_width":0,"photo_height":0,"description":"wrdqw","caption":"wer","id":"46156165165","title":"123","message_text":"123","parse_mode":"Markdown","thumb_url":"http://weknowyourdreams.com/images/car/car-05.jpg","disable_web_page_preview":false}],"cache_time":300,"is_personal":false,"next_offset":"0"}
根据本文档,这是我的AnswerInlineQuery结构:https://core.telegram.org/bots/api#answerinlinequery
public class AnswerInlineQuery
{
public string InlineQueryId { get; set; }
public List<InlineQueryResult> Results { get; set; }
public int CacheTime { get; set; }
public bool IsPersonal { get; set; }
public string NextOffset { get; set; }
}
和&#34; InlineQueryResult&#34; :
public class InlineQueryResult
{
public string Id { get; set; }
public string Title { get; set; }
public string MessageText { get; set; }
public string ParseMode { get; set; }
public string ThumbUrl { get; set; }
public bool DisableWebPagePreview { get; set; }
}
和&#34; InlineQueryResultPhoto&#34; :
public class InlineQueryResultPhoto : InlineQueryResult
{
public string Type => "photo";
public string PhotoUrl { get; set; }
public int PhotoWidth { get; set; }
public int PhotoHeight { get; set; }
public string Description { get; set; }
public string Caption { get; set; }
}
我尝试传递这样的空结果:
Bot.AnswerInlineQuery(new AnswerInlineQuery
{
InlineQueryId = inlinequery.Id,
Results = new List<InlineQueryResult>(),
IsPersonal = false,
CacheTime = 300,
NextOffset = "0"
});
但我再次得到同样的错误,似乎问题不在&#34;结果&#34; !
我不知道它意味着哪个号码,并尝试使用许多不同数据的Json,但我无法修复它,我的Json结构是错误的吗?任何想法?
谢谢。
答案 0 :(得分:3)
问题解决了,结果参数必须是字符串变量包含结果不完全是Json数组的Json数组:
nix-shell