Конечная точка, которую я использую, похожа на
Код: Выделить всё
https://graph.facebook.com/{media_id}?caption={new_caption}&access_token={access_token}

Ни использование бессонницы, ни используя код JAVA, я получу успешное сообщение, а заголовок останется неизменным.
Код: Выделить всё
private static CompletableFuture
updatePostInstagramMessageAsync(String hostname, PostFB ig, HttpClient client) {
JSONObject jsonPayload = new JSONObject();
if (ig.text != null && !ig.text.isEmpty()) {
jsonPayload.put("caption", ig.text);
jsonPayload.put("comment_enabled", true);
System.out.println("jsonPayload is " + jsonPayload.toString());
String url = "https://graph.facebook.com/v19.0/" + "my postID";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?access_token=" + ig.page_access_token))
.header("Content-Type", "application/json")
.method("POST", BodyPublishers.ofString(jsonPayload.toString(), StandardCharsets.UTF_8))
.build();
return client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(response -> {
System.out.println("Response for updating post is " + response.body());
if (response.statusCode() == 200) {
System.out.println("Updated post successfully.");
} else {
System.out.println("Failed to update post: " + response.body());
}
} else {
System.out.println("Failed to update post. Status code: " + response.statusCode());
}
return ig;
})
.exceptionally(ex -> {
ex.printStackTrace();
return ig;
});
} else {
return CompletableFuture.completedFuture(null);
}
}
Я создал приложение и назначил необходимые разрешения:
- pages_show_list,
- instagram_basic,
- instagram_manage_comments,
- instagram_manage_insights,
instagram_content_publish, - instagram_manage_messages,
- pages_read_engagement,
- instagram_manage_events,< /li>
public_profile
Будем благодарны за любую помощь.
Подробнее здесь: https://stackoverflow.com/questions/785 ... lly-workin