Mein Englisch ist Not the yellow from the egg.
https://youtu.be/0jJ3X5nvBB8
Und ist das dann nicht Schleichwerbung?
Moin an alle,
ich würde gerne auf die Twitch API zugreifen und abfragen ob ein bestimmter Kanal grade Streamt.
Hier der Code:
String Streamer = "Test";
URL url;
HttpURLConnection connection = null;
try{
//create connection
url = new URL(("https://api.twitch.tv/kraken/channels/" + Streamer));
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Client-ID",
Secrets.twitch_clientid);
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
//Send request
DataOutputStream wr = new DataOutputStream(
connection.getOutputStream());
//Get response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while((line = rd.readLine()) != null){
response.append(line);
response.append('\r');
}
rd.close();
System.out.println(response.toString());
} catch (Exception e){
e.printStackTrace();
System.out.println("NULL");
} finally {
if (connection != null) {
connection.disconnect();
}
}
Was ich als Output bekomme:
java.io.FileNotFoundException: https://api.twitch.tv/kraken/channels/Test
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1923)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1523)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
at me.duncte123.ge.commands.cmdTest.handle(cmdTest.java:47)
at me.duncte123.ge.CommandManager.handleCommand(CommandManager.java:59)
at me.duncte123.ge.Listener.onGuildMessageReceived(Listener.java:60)
at net.dv8tion.jda.core.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:381)
at net.dv8tion.jda.core.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:84)
at net.dv8tion.jda.core.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:95)
at net.dv8tion.jda.core.handle.SocketHandler.handle(SocketHandler.java:37)
at net.dv8tion.jda.core.requests.WebSocketClient.onDispatch(WebSocketClient.java:868)
at
Hat jemand dasselbe Problem auch mal gehabt? Mache ich etwas falsch?
Gruß
Dennis