我需要在内联模式下使用bot,并且我使用java开源库来处理对电报API的RESTful请求。可以在此链接https://github.com/pengrad/java-telegram-bot-api找到该库。我试着这样做:
String query = inlineQuery.query().trim().toLowerCase();
List<String> answerList = new LinkedList<String>();
answerList.add("first_answer");
answerList.add("second_answer");
InlineQueryResult[] resArray = new InlineQueryResult[answerList.size()];
for (int j = 0; j < resArray.length; j++)}{
resArray[j] = new InlineQueryResultArticle(inlineQuery.id(), answerList.get(j), query);
}
bot.answerInlineQuery(inlineQuery.id(), resArray);
但我在运行时有这个例外
Exception in thread "main" retrofit.RetrofitError: 400 Bad Request
我将InlineQueryResultArticle
构造函数的第一个参数从inlineQuery.id()
编辑为"id_"+j
,现在可以正常工作。
答案 0 :(得分:0)
尝试使用2.0.0版本的库。 现在响应对象中返回错误消息。 还有一个API更改