Pregunta

Quiero iniciar sesión en Hotfile y Fileserve con mi aplicación Java; Yo uso apache.

public static void main(String[] args) throws Exception {

    DefaultHttpClient httpclient = new DefaultHttpClient();

    HttpGet httpget = new HttpGet("http://www.hotfile.com/");

    HttpResponse response = httpclient.execute(httpget);
    HttpEntity entity = response.getEntity();

    System.out.println("Login form get: " + response.getStatusLine());
    if (entity != null) {
        entity.consumeContent();
    }
    System.out.println("Initial set of cookies:");
    List<Cookie> cookies = httpclient.getCookieStore().getCookies();
    if (cookies.isEmpty()) {
        System.out.println("None");
    } else {
        for (int i = 0; i < cookies.size(); i++) {
            System.out.println("- " + cookies.get(i).toString());
        }
    }

    HttpPost httpost = new HttpPost("http://www.hotfile.com/index.php");

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();

    nvps.add(new BasicNameValuePair("user", "myuser"));
    nvps.add(new BasicNameValuePair("pass", "mypass"));
    nvps.add(new BasicNameValuePair("returnto", "/"));
    httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

    response = httpclient.execute(httpost);

    System.out.println("Response " + response.toString());
    entity = response.getEntity();

    System.out.println("Login form get: " + response.getStatusLine());
    if (entity != null) {
        InputStream is = entity.getContent();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String str = "";
        while ((str = br.readLine()) != null) {
            System.out.println("" + str);
        }
    }

    System.out.println("Post logon cookies:");
    cookies = httpclient.getCookieStore().getCookies();
    if (cookies.isEmpty()) {
        System.out.println("None");
    } else {
        for (int i = 0; i < cookies.size(); i++) {
            System.out.println("- " + cookies.get(i).toString());
        }
    }
    httpclient.getConnectionManager().shutdown();
}


pero no funciona.¿Cómo puedo iniciar sesión en estos sitios?

¿Fue útil?

Solución

Use their API, mate, http://api.hotfile.com/.

Example: http://api.hotfile.com/?action=getuserinfo&username=myuser&password=mypass

Example return results: is_premium=0&hotlink_traffic_kb=70

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top