String url=" url?access_token="+access_token; HttpGet request=new HttpGet(url); System.out.println("保存的access_token="+access_token);HttpClient client=new GetDefaultClient().getNewHttpClient(); try{ HttpResponse response=client.execute(request); int code=response.getStatusLine().getStatusCode();if (code == 200){ InputStream is = response.getEntity().getContent();BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));StringBuilder buffer = new StringBuilder();try{String line;while ((line=reader.readLine())!=null){buffer.append(line);}} finally{reader.close();}String string = buffer.toString();System.out.println(string); //return Integer.parseInt(string); }} catch (UnsupportedEncodingException e){// TODO Auto-generated catch blocke.printStackTrace();} catch (ClientProtocolException e){// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e){// TODO Auto-generated catch blocke.printStackTrace();} }
时间: 2024-10-06 22:53:00