Hello! Can anyone suggest either the existence of a Curl interpreter in Java, or what (at least approximately) analogue of Java code will be from this query:

curl -i -X POST --data-urlencode "oauth_consumer_key=ЗНАЧЕНИЕ" -- data-urlencode "oauth_nonce=значение" --data-urlencode "oauth_signature_method=HMAC-SHA1" --data-urlencode "oauth_timestamp=значение" --data-urlencode "oauth_version=1.0" --data- urlencode "oauth_token=значение" --data-urlencode "auth_signature=значение" --data "category=3" --data-urlencode "title=Новое название" --data-urlencode "description=Краткое описание" --data-urlencode "message=Полное описание" --data "end2br_desc=1&includehtml_desc=no" http://yoursite.ucoz.ru/uapi/news 

Thank you for your reply!

    1 answer 1

    You need to think not about the wrapper over Curl, but about the HTTP client in principle. For Java, there are a lot of implementations of HTTP clients. One of the most famous is Apache HttpComponents / HttpClient

     HttpClient httpClient = HttpClients.createDefault(); HttpUriRequest request = RequestBuilder.post("http://yoursite.ucoz.ru/uapi/news") .addParameter("oauth_consumer_key", "ЗНАЧЕНИЕ") .addParameter("oauth_nonce", "значение") .addParameter("oauth_signature_method", "HMAC-SHA1") .addParameter("oauth_timestamp", "значение") .addParameter("oauth_version", "1.0") .addParameter("oauth_token", "значение") .addParameter("auth_signature", "значение") .addParameter("title", "Новое название") .addParameter("description", "Краткое описание") .addParameter("message", "Полное описание") .setEntity(new UrlEncodedFormEntity(Arrays.asList( new BasicNameValuePair("end2br_desc", "1"), new BasicNameValuePair("includehtml_desc", "no") ))).build(); HttpResponse response = httpClient.execute(request); 
    • ♦ Thank you for your help! - Sergey