So, what I’m trying to do is use a java CLI program running both a twitch and discord bot to connect to the webhook system to auto ping on stream status changing, but I seem to be running into an issue.
Is this something that’s even possible using java? Am I just trying to call the initial …/…/hub url wrong? Any assistance would be appreciated.
String payload = "{" +
"\"hub.callback\": \"http://IP.of.my.raspberrypi:4568\", " +
"\"hub.mode\": \"subscribe\", " +
"\"hub.lease_seconds\": \"50000\", " +
"\"hub.topic\": \"https://api.twitch.tv/helix/users/follows?first=1&from_id=64207063\"" +
"}";
StringEntity entity = new StringEntity(payload,
ContentType.APPLICATION_FORM_URLENCODED);
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("https://api.twitch.tv/helix/webhooks/hub");
request.setEntity(entity);
request.setHeader("Accept", "application/json");
request.setHeader("Client-ID", "IDHERE" );
request.setHeader("Authorization", "OAuth OAUTHHERE" );
request.setHeader("Content-Type", "application/json; utf-8" );
HttpResponse response = httpClient.execute(request);
System.out.println(response.getStatusLine().getStatusCode());
That’s the rough base for calling the initial URL. The URL points to the IP of my raspberry pi, which is running a java web server which SHOULD, from my understanding, be able to handle the response just fine, however trying to test the code above gives me a 400 error and I’m not entirely sure why.