Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. httppost.setHeader("Content-type", "application/json");
  2.  
  3. public void parse(String last, String pwd){
  4. String lastIndex = last;
  5. DefaultHttpClient http = new DefaultHttpClient(new BasicHttpParams());
  6. System.out.println("URL is: "+CONNECT_URL);
  7. HttpPost httppost = new HttpPost(CONNECT_URL);
  8. httppost.setHeader("Content-type", "application/json");
  9. try{
  10.  
  11. List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
  12. nameValuePairs.add(new BasicNameValuePair("key", password));
  13. nameValuePairs.add(new BasicNameValuePair("last_index", lastIndex));
  14.  
  15. httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  16.  
  17.  
  18.  
  19. System.out.println("Post variables(Key): "+password+"");
  20. System.out.println("Post variables(last index): "+lastIndex);
  21.  
  22.  
  23.  
  24.  
  25. HttpResponse resp = http.execute(httppost);
  26. HttpEntity entity = resp.getEntity();
  27. ins = entity.getContent();
  28.  
  29.  
  30. BufferedReader bufread = new BufferedReader(new InputStreamReader(ins, "UTF-8"), 8);
  31. StringBuilder sb = new StringBuilder();
  32. String line = null;
  33.  
  34. while((line = bufread.readLine()) != null){
  35. sb.append(line +"n");
  36. }
  37. result = sb.toString();
  38. System.out.println("Result: "+result);
  39.  
  40.  
  41.  
  42. // readAndParseJSON(result);
  43. }catch (Exception e){
  44. System.out.println("Error: "+e);
  45. }finally{
  46. try{
  47. if(ins != null){
  48. ins.close();
  49. }
  50. }catch(Exception smash){
  51. System.out.println("Squish: "+smash);
  52. }
  53. }
  54. // return result;
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement