所以我有一些已经使用了几个月的代码,但是最近它突然停止了。它向Anilist API发出请求,以获取有关某些动漫的信息。
try {
String query = getQuery();
query = query.replace("\n", " ").replace(" ", " ");
URL url = new URL("https://graphql.anilist.co");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
conn.addRequestProperty("Accept", "application/json");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
OutputStream os = conn.getOutputStream();
os.write(query.getBytes("UTF-8"));
os.close();
// read the response
InputStream in = new BufferedInputStream(conn.getInputStream());
String result = org.apache.commons.io.IOUtils.toString(in, "UTF-8");
in.close();
conn.disconnect();
//return result
} catch (Exception exp) {
System.out.println("exception TRIGGERED");
System.out.println(exp.getLocalizedMessage());
}
因此,我设置了断点,并且似乎在注释“ //读取响应”之后的行处断了。我已经尝试使用针对Google chrome的 Altair GraphQL Client 扩展名和https://anilist.co/graphiql上的建议工具来尝试相同的请求,它们都可以工作,因此问题似乎与我的代码有关,但是我尚未更新环境。我也有一个在aws上运行的代码实例(它是不和谐bot的一部分),而且我知道自从将bot放到那里以来,我还没有碰过。 如果您有兴趣,我知道曾经使用过的查询之一是
{"query":"query {
Media (type: ANIME, search: "naruto") {
id
idMal
type
description(asHtml:false)
chapters
format
episodes
source
genres
averageScore
popularity
isAdult
status
nextAiringEpisode {
episode
airingAt
timeUntilAiring
}
startDate {
year
month
day
}
season
title {
english
native
romaji
}
coverImage{
large
medium
}
studios (isMain: true) {
nodes {
id
name
}
}
}
}"}
感谢您的帮助,非常感谢。