How to download instagram private post in android

1.1k Views Asked by At

I am creating a Instagram post downloader android app. how to i download private pictures and videos from Instagram by copy share URL in android. I use the below code. Please help me which is missing in this code.

 if (stringData.matches("https://www.instagram.com/(.*)")) {
            String[] data = stringData.split(Pattern.quote("?"));
            String string = data[0];
            Log.i("TAG", "data: string "+string);
            if (isNetworkAvailable()) {
                Log.i("TAG", "data: isNetworkAvailable IF "+isNetworkAvailable());

                if (Method.isDownload) {

                    Log.i("TAG", "data: Method.isDownload IF "+Method.isDownload);

                    AsyncHttpClient client = new AsyncHttpClient();
                    client.get(string + "?__a=1", null, new AsyncHttpResponseHandler() {
                        @Override
                        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {

                        }

                        @Override
                        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                            //Some thing went to wrong
                        }
                    });
                } else {
                    //First of all one download complete then after you can another download
                }
            } else {
              //No Internet Connection
            }
        } else {
            //No supported
        }
1

There are 1 best solutions below

1
On

There is no problem with this code, you can download profile pic from public profiles. But as soon as you access the data from the private account you get an error. You have to give login credentials for that Instagram account in order to fetch the private data.