Esempio n. 1
0
    @Override
    protected Void doInBackground(Void... params) {
      String url = Constants.URL_REGISTER_PUSH + _id + "&provider=ANDROID";
      HttpEntity httpEntity = null;
      HttpClient client = new DefaultHttpClient();
      ServiceHandler sh = new ServiceHandler();
      try {
        client.getConnectionManager().getSchemeRegistry().register(sh.getMockedScheme());
      } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      HttpGet method = new HttpGet(url);
      method.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
      method.setHeader("Authorization", token.getToken_type() + " " + token.getAccess_token());
      try {
        HttpResponse response = client.execute(method);
        httpEntity = response.getEntity();

      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      } catch (ClientProtocolException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return null;
    }
Esempio n. 2
0
    private HttpResponse doResponse(String url) {

      // Use our connection and data timeouts as parameters for our
      // DefaultHttpClient
      HttpClient httpclient = new DefaultHttpClient(getHttpParams());
      ServiceHandler sh = new ServiceHandler();
      try {
        httpclient.getConnectionManager().getSchemeRegistry().register(sh.getMockedScheme());
      } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      HttpResponse response = null;

      try {

        switch (taskType) {
          case POST_TASK:
            HttpPost httppost = new HttpPost(url);
            // Add parameters
            httppost.setEntity(new UrlEncodedFormEntity(params));

            response = httpclient.execute(httppost);
            break;
          case GET_TASK:
            HttpGet httpget = new HttpGet(url);
            httpget.setHeader(
                "Authorization",
                "Bearer pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg");
            // response.setHeader("Authorization",
            // "Bearer
            // pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg");
            // httpget.addHeader("Authorization",
            // "Bearer
            // pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg");
            Client client = new Client();
            // response = client.
            response = httpclient.execute(httpget);
            // response.addHeader("Authorization",
            // "Bearer
            // pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg");
            break;
        }
      } catch (Exception e) {

        Log.e(TAG, e.getLocalizedMessage(), e);
      }

      return response;
    }
Esempio n. 3
0
    @Override
    protected Void doInBackground(Void... params) {

      nameValuePairs.add(new BasicNameValuePair("Email", dto.getEmail()));
      nameValuePairs.add(new BasicNameValuePair("FirstName", dto.getFirstName()));
      nameValuePairs.add(new BasicNameValuePair("LastName", dto.getLastName()));
      nameValuePairs.add(new BasicNameValuePair("MobileNo", dto.getMobileNo()));
      nameValuePairs.add(new BasicNameValuePair("Password", dto.getPassword()));
      nameValuePairs.add(new BasicNameValuePair("ConfirmPassword", dto.getConfirmPassword()));

      jsonStr = sh.makeServiceCall(Constants.URL_REGISTER, ServiceHandler.POST, nameValuePairs);
      if (!jsonStr.equalsIgnoreCase("")) {
        try {
          JSONObject object1;
          object1 = new JSONObject(jsonStr);
          JSONObject ModelState = object1.getJSONObject("ModelState");
          JSONArray arrModelState = ModelState.getJSONArray("");
          errRegister = arrModelState.getString(1);

        } catch (Exception e) {

        }
      } else {

      }
      return null;
    }