Open fullky opened 2 years ago
Tigase XMPP Server does not support api_key
but only api-key
parameter
Tigase XMPP服务器不支持
api_key
,但只有api-key
参数
How do I use it?
This is my code, error reported 302 temporary redirection
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://im.aeeago.com:8080/rest/stream");
String sendString ="<message xmlns=\"jabber:client\" type=\"chat\" to=\"zcy@im.aeeago.com\"><body>{\"type\":1,\"msgid\":\"dsf\",\"content\":\"test\"} </body></message>";
System.out.println(sendString);
StringEntity entity = new StringEntity(sendString,"utf-8");
entity.setContentType("application/xml");
entity.setContentEncoding("utf-8");
post.setEntity(entity);
HttpResponse response= null;
try {
response = client.execute(post);
} catch (IOException e) {
e.printStackTrace();
}```
Tigase XMPP服务器不支持
api_key
,但只有api-key
参数
What should I do with "each request needs to be authorized by sending a valid administrator JID and password as user and password of BASIC HTTP authorization method." in the document? The error I am reporting is 403 Forbidden,
In order to make HTTP request you need to:
1) pass api-key
(configured in HTTP api key repository via admin web ui)
2) authenticate the request using HTTP Basic access authentication. You can find how to do that using search engine: duckduckgo: java httpclient basic auth, eg.:
val httpClient: HttpClient = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.authenticator(object : Authenticator() {
override fun getPasswordAuthentication(): PasswordAuthentication {
return PasswordAuthentication("admin", "password".toCharArray())
}
})
.version(HttpClient.Version.HTTP_1_1)
.build()
val request = HttpRequest.newBuilder()
.GET()
.uri(URI.create("http://im.aeeago.com:8080/rest/stream"))
.build()
val httpResponse = httpClient.send(request, BodyHandlers.ofString())
println("httpResponse statusCode = ${httpResponse.statusCode()}")
println(httpResponse.body())
I have a problem with… After I pass "api_key" as a parameter, I report an error of "302 temporary redirection". After I write "open_access" in the configuration file, I do not pass "api_key", but I also report the same error of temporary redirection. There is no configuration about redirection in my configuration file. How should I solve it? Thank you very much Details (please complete the following information):