简体   繁体   中英

Android - Accessing member's only websites from application

I'm trying to create an app for a certain website that has no mobile version to offer. The method I'm using is that I download the source code based on URL and read everything I want from it. Unfortunately, the website requires logging in to access the critical information.

When I download source code from the URL https://domain.com?user=user_name&pass=password , the site greets me by showing that user_name is logged in. But when I try to access member's only sites, for example, https://domain.com/members/page_1/ , the source code shows me "Access error". So the problem is that the cookies don't stay alive.

Source code download function:

private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
    @Override
    protected String doInBackground(String... urls) {
        String response = "";
        for (String url : urls) {
            Log.d(TAG, url);
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(url);
            try {
                HttpResponse execute = client.execute(httpGet);
                InputStream content = execute.getEntity().getContent();

                BufferedReader buffer = new BufferedReader(
                        new InputStreamReader(content));
                String s = "";
                while ((s = buffer.readLine()) != null) {
                    response += s;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return response;
    }
}

I'm just here to say

NEVER PUT THE PASSWORD IN THE URL.

It is a huge security concern.


In terms of the cookies staying alive part, you should be looking at the HTTP requests as they arrive to ensure that the actually do have the 'Set-Cookie' header on them. From the OP, it seems like the site is not actually issuing you any cookies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM