廣告

2015年3月15日 星期日

[java] Add parameter to httpGet Url by NameValuePair


 ArrayList pairList = new ArrayList();
            pairList.add(new BasicNameValuePair("serviceToken",(String) map.get("serviceToken") ));
            log.info("data to LinkingData:"+pairList.toString());
            String paramString = URLEncodedUtils.format(pairList, "utf-8");
            
            String getUrl = ApiUrl+GetTagListUrl+"?"+paramString;
            System.out.println(getUrl);
            HttpGet request = new HttpGet(getUrl);
            request.setHeader("Content-Type", "application/json");
            
            HttpResponse response = httpClient.execute(request);

            BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
           
            for (String temp = ""; temp != null; temp = br.readLine()) {
                //System.out.println(temp);
                output += temp;
            }

沒有留言:

張貼留言