Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- httppost.setHeader("Content-type", "application/json");
- public void parse(String last, String pwd){
- String lastIndex = last;
- DefaultHttpClient http = new DefaultHttpClient(new BasicHttpParams());
- System.out.println("URL is: "+CONNECT_URL);
- HttpPost httppost = new HttpPost(CONNECT_URL);
- httppost.setHeader("Content-type", "application/json");
- try{
- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
- nameValuePairs.add(new BasicNameValuePair("key", password));
- nameValuePairs.add(new BasicNameValuePair("last_index", lastIndex));
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- System.out.println("Post variables(Key): "+password+"");
- System.out.println("Post variables(last index): "+lastIndex);
- HttpResponse resp = http.execute(httppost);
- HttpEntity entity = resp.getEntity();
- ins = entity.getContent();
- BufferedReader bufread = new BufferedReader(new InputStreamReader(ins, "UTF-8"), 8);
- StringBuilder sb = new StringBuilder();
- String line = null;
- while((line = bufread.readLine()) != null){
- sb.append(line +"n");
- }
- result = sb.toString();
- System.out.println("Result: "+result);
- // readAndParseJSON(result);
- }catch (Exception e){
- System.out.println("Error: "+e);
- }finally{
- try{
- if(ins != null){
- ins.close();
- }
- }catch(Exception smash){
- System.out.println("Squish: "+smash);
- }
- }
- // return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement