Skip to content

Commit d325dff

Browse files
mbayoumbayoukohlerpop1
authored
Fix: API Key added in the body instead of param (#142)
* Fix: Add the missing API Key on send chat calls. * Fix: Wrongly added the apiKey in the body instead of the param * Update TikTokLiveHttpClient.java We do not need to null check as Eulerstream verifies anyway so we can just pass whatever the value is. * Update TikTokLiveHttpClient.java Revert to your method, but using Header instead of Param, since HttpClient does not allow null values! Co-authored-by: mbayou <mathieu@novasquare.io> Co-authored-by: kohlerpop1 <70915561+kohlerpop1@users.noreply.github.com>
1 parent dac688e commit d325dff

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpClient.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,11 @@ public boolean requestSendChat(LiveRoomInfo roomInfo, String content) {
204204
body.addProperty("sessionId", clientSettings.getSessionId());
205205
body.addProperty("ttTargetIdc", clientSettings.getTtTargetIdc());
206206
body.addProperty("roomId", roomInfo.getRoomId());
207+
HttpClientBuilder builder = httpFactory.client(TIKTOK_CHAT_URL)
208+
.withHeader("Content-Type", "application/json");
207209
if (clientSettings.getApiKey() != null)
208-
body.addProperty("apiKey", clientSettings.getApiKey());
209-
var result = httpFactory.client(TIKTOK_CHAT_URL)
210-
.withHeader("Content-Type", "application/json")
211-
.withBody(HttpRequest.BodyPublishers.ofString(body.toString()))
212-
.build()
213-
.toJsonResponse();
210+
builder.withHeader("apiKey", clientSettings.getApiKey());
211+
var result = builder.withBody(HttpRequest.BodyPublishers.ofString(body.toString())).build().toJsonResponse();
214212
return result.isSuccess();
215213
}
216214

@@ -243,4 +241,4 @@ protected ActionResult<HttpResponse<byte[]>> getByteResponse(String room_id) {
243241

244242
return result;
245243
}
246-
}
244+
}

0 commit comments

Comments
 (0)