Skip to content

Instantly share code, notes, and snippets.

@SaadArdati
Created May 16, 2015 08:11
Show Gist options
  • Save SaadArdati/74ac4f9228cd8001bcdc to your computer and use it in GitHub Desktop.
Save SaadArdati/74ac4f9228cd8001bcdc to your computer and use it in GitHub Desktop.
Twitter Validater Fixed
public static boolean twitterAccountIsValid(String username) {
try {
URL u = new URL("https://www.twitter.com/" + username.replace("@", ""));
HttpURLConnection huc = (HttpURLConnection) u.openConnection();
huc.setRequestMethod("HEAD");
huc.connect();
return huc.getResponseCode() == 200;
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment