D
D
dimasta682017-05-29 19:18:49
Android
dimasta68, 2017-05-29 19:18:49

Post get requests android on https?

good day) such a problem was written by a client on android used the JSONParser library everything worked fine until the site on which the api is located did not change to https
here is a code example of how to make requests to api

class GetCheckBanID extends AsyncTask<Object, Object, JSONObject> {
        /**
         * Перед началом показать в фоновом потоке прогресс диалог
         **/
        @Override
        protected void onPreExecute() {
            super.onPreExecute();

        }

        /**
         * Получение детальной информации о продукте в фоновом режиме
         **/
        protected JSONObject doInBackground(Object... params) {

            // получаем продукт по HTTP запросу

            int success;
            JSONObject product = null;
            try {

                // Список параметров
                List<NameValuePair> param = new ArrayList<NameValuePair>();
                param.add(new BasicNameValuePair("pid", '"'+android_id+'"'));

                JSONObject json = jsonParser.makeHttpRequest(url_check_ban_id, "GET", param);

                Log.d("prefLog", param.toString());

                success = json.getInt(TAG_SUCCESS);
                if (success == 1) {
                    // Успешно получинна детальная информация о продукте
                    JSONArray productObj = json.getJSONArray(TAG_PRODUCT);

                    // получаем первый обьект с JSON Array
                    product = productObj.getJSONObject(0);
                    checkBan = 4;
                    Log.d("prefLog", "check ban android_id find");
                } else {
                    checkBan = 1;
                    Log.d("prefLog", "ban not found ander id");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }


            return product;
        }

        /**
         * После завершения фоновой задачи закрываем диалог прогресс
         **/
        protected void onPostExecute(JSONObject resault) {
            Log.d("myLog", "results === " + resault);

            new GetProductDetails().execute();
        }
    }

is there any solution for this problem? ? ?
thanks in advance )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Kazantsev, 2017-05-31
@saintbyte

As far as I remember, Https and httpConnection have the same base class - you need to work with its properties and methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question