-
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(); }```
-
In order to make HTTP request you need to:
- pass
api-key
(configured in HTTP api key repository via admin web ui) - 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())
- pass
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):