Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url = "http://54.37.137.53:8260/todolist/app/core/action/fixapi.php";
- String charset = "UTF-8"; // Or in Java 7 and later, use the constant: java.nio.charset.StandardCharsets.UTF_8.name()
- String method = "login";
- String login = "admin@admin.pl";
- String password = "admin123";
- // ...
- String query = String.format("method=%s&login=%s&password=%s",
- URLEncoder.encode(method, charset),
- URLEncoder.encode(login, charset),
- URLEncoder.encode(password, charset));
- URLConnection connection = new URL(url).openConnection();
- connection.setDoOutput(true); // Triggers POST.
- connection.setRequestProperty("Accept-Charset", charset);
- connection.setRequestProperty("Content-Type", "application/json;charset=" + charset);
- try (OutputStream output = connection.getOutputStream()) {
- output.write(query.getBytes(charset));
- }
- InputStream response = connection.getInputStream();
- System.out.print(response); // W ZMIENNEJ RESPONSE JEST WYNIK, SPRAWDZ CO W NIM SIE ZNAJDUJE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement