Created
June 2, 2009 05:34
-
-
Save elight/122078 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
URL url = new URL (urlStr); | |
String encoding = Base64Coder.encodeString(authInfo); | |
// Need to work with URLConnection to set request property | |
URLConnection uc = url.openConnection(); | |
uc.setRequestProperty ("Authorization", "Basic " + encoding); | |
BufferedReader rd = new BufferedReader(new InputStreamReader(uc.getInputStream())); | |
StringBuffer sb = new StringBuffer(); | |
String line; | |
while ((line = rd.readLine()) != null) { sb.append(line); } | |
JSONTokener tokener = new JSONTokener(sb.toString()); | |
JSONArray array = new JSONArray(tokener); | |
JSONObject tweetJSON = null; | |
for(int i=0; i<array.length(); i++) { | |
tweets.add(new Tweet((JSONObject) array.get(i))); | |
} | |
} catch (MalformedURLException e) { | |
Log.e(APP_NAME, "Invalid URL"); | |
} catch (IOException e) { | |
Log.e(APP_NAME, "Error reading URL"); | |
} catch(JSONException e) { | |
Log.e(APP_NAME, e.getMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment