예제 #1
0
 private String search() {
   String query = "sessionId=" + Sscion.getSsid() + "&" + "pageno=" + 1;
   HttpGet httpRequest = new HttpGet(URLs.ASK_URL + query);
   String strResult = " ";
   try {
     HttpClient httpClient = new DefaultHttpClient();
     HttpResponse httpResponse = httpClient.execute(httpRequest);
     if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
       strResult = EntityUtils.toString(httpResponse.getEntity());
     }
     result = JsonUtils.fjson2(strResult);
   } catch (ClientProtocolException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (ParseException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return result;
 }
예제 #2
0
 private String outlogin() throws JSONException {
   HttpGet httpRequest = new HttpGet(URLs.ASK_TEACHER + "sessionId=" + Sscion.getSsid());
   String strResult = "";
   try {
     HttpClient httpClient = new DefaultHttpClient();
     HttpResponse httpResponse = httpClient.execute(httpRequest);
     if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
       strResult = EntityUtils.toString(httpResponse.getEntity());
     }
     JSONArray jsonArray = new JSONArray(strResult);
     for (int i = 0; i < jsonArray.length(); i++) {
       JSONObject sc = jsonArray.getJSONObject(i);
       JSONObject item = sc.getJSONObject("accessFlag");
       accessFlag = item.getString("flag");
       describe = item.getString("describe");
     }
   } catch (ClientProtocolException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return accessFlag;
 }
예제 #3
0
  /** 请求签到次数 */
  public void loadMessageData() {
    HttpUtils http = new HttpUtils();
    RequestParams params = new RequestParams();
    params.addQueryStringParameter("sessionId", Sscion.getSsid());
    http.send(
        HttpMethod.GET,
        URLs.qIANDAOTIME,
        params,
        new RequestCallBack<String>() {
          @Override
          public void onSuccess(ResponseInfo<String> responseInfo) {
            stopProgressDialog();
            try {
              JSONArray jsonObject = new JSONArray(responseInfo.result);
              String aaString = jsonObject.getJSONObject(0).get("loadTimes").toString();
              Intent intent2 = new Intent(MainActivity.this, SignActivity.class);
              intent2.putExtra("times", aaString);
              startActivity(intent2);
              /*JSONObject accessFlagArray = jsonArray.getJSONObject(0).getJSONObject("loadTimes");
              flag=accessFlagArray.getString("flag");
              if (flag.equals("6")) {
              }
              describe=accessFlagArray.getString("describe");*/
            } catch (JsonParseException e) {
              AppException.json(e).makeToast(MainActivity.this);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }

          @Override
          public void onStart() {
            startProgressDialog();
          }

          @Override
          public void onFailure(HttpException error, String msg) {
            stopProgressDialog();
          }
        });
  }