1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
//page de traitement de la requete POST
HttpPost httppost = new HttpPost(this.adresse+"index.php?page=login");
//liste qui contiendra tous les parametres
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//rajout des parametres
nameValuePairs.add(new BasicNameValuePair("pseudo", pseudo));
nameValuePairs.add(new BasicNameValuePair("passe", mdp));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// on construit le client http
HttpClient httpclient = new DefaultHttpClient();
// derriere un proxy
HttpHost proxy = new HttpHost(***);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
// autres parametres...
httppost.setHeader("httpclient.useragent","Mozilla/4.0"); /*j'ai ajoute ceci pour voir au cas ou ca regle mon probleme, mais non*/
// connexion
httpclient.execute(httppost);
// nouvelle URL
HttpGet httpget = new HttpGet(this.adresse+"index.php?page=autrepage");
// recuperation du code source
HttpResponse response = httpclient.execute(httpget);
// avec affichage du contenu
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String s;
while((s = reader.readLine()) != null){
System.out.println(s);
}
// partie a completer une fois que le debut marchera
// ... |
Partager