Android : Execute HttpPost with google token in android is not fetching JSON data

on Wednesday, July 30, 2014



HttpPost httpPost = new HttpPost("MyWebsiteURL");
try {
httpPost.setEntity(new StringEntity("https://www.googleapis.com/plus/v1/people/me?key="+token));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream is = httpEntity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
String json = sb.toString();
Log.i("JSON", json);

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

0 comments:

Post a Comment