Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- URL url = new URL(API_URL + "apikey=" + API_KEY + "&username=" + email + "&password=" + password);
- //http://staging.symptoma.com/api/v2/ping?apikey=9b5e5c01f2eb86bb3882af9dbab21ca1
- //URL url = new URL(API_URL + "apikey=" + API_KEY);
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setRequestMethod("GET");
- //urlConnection.setRequestProperty("Authorization","Basic" + encoding);
- //urlConnection.setDoOutput(false);
- Authenticator.setDefault(new CustomAuthenticator());
- urlConnection.connect();
- int status = urlConnection.getResponseCode();
- if (status >= 400) {
- if (status == 404 || status == 410) {
- throw new FileNotFoundException(url.toString());
- } else {
- throw new java.io.IOException(
- "Server returned HTTP"
- + " response code: " + status
- + " for URL: " + url.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement