groRelou
Messages postés2Date d'inscriptionjeudi 19 mai 2005StatutMembreDernière intervention10 juin 2011
-
10 juin 2011 à 13:25
groRelou
Messages postés2Date d'inscriptionjeudi 19 mai 2005StatutMembreDernière intervention10 juin 2011
-
10 juin 2011 à 13:26
Alors j'ai pu trouvé 2 manières pour s'authentifier a un serveur http mais elle ne fonctionne pas.
private static String downloadPage(URL url){
URLConnection conn = null;
InputStreamReader in;
BufferedReader data;
String line;
StringBuffer buf = new StringBuffer();
try {
conn = url.openConnection();
// HttpURLConnection.setFollowRedirects(true);
String user ="";
String pass ="";
String userpass = user+":"+pass;
String basicAuth = "Basic " + new String(new Base64().encode(userpass.getBytes()));
conn.setRequestProperty ("Authorization", basicAuth);
conn.connect();
in = new InputStreamReader(conn.getInputStream());
data = new BufferedReader(in);
while ((line = data.readLine()) != null){
buf.append(line + "\n");
}
return buf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
j'ai essayé:
static class MyAuthenticator extends Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
// I haven't checked getRequestingScheme() here, since for NTLM
// and Negotiate, the usrname and password are all the same.
System.err.println("Feeding username and password for " + getRequestingScheme());
return (new PasswordAuthentication(kuser, kpass.toCharArray()));
}
}
public static void main(String args[]) // Le main...
{
Authenticator.setDefault(new MyAuthenticator());
String page = downloadPage(new URL("http://m.facebook.com/#!/unpseudo"));
try{
FileWriter fw = new FileWriter("lapage.txt");
fw.write(p.getData());
fw.close();;
}catch(Exception e){
e.printStackTrace();
}
}
Ce qu'on voit dans lapage.txt c'est qu'on a le code source de la page tel qu'on la verrait si on n'était pas authentifié a facebook.
En gros ma question c'est comment faire pour etre identifier à facebook mobile ?
groRelou
Messages postés2Date d'inscriptionjeudi 19 mai 2005StatutMembreDernière intervention10 juin 2011 10 juin 2011 à 13:26
C'est encore moi !
On me dit que l'authentification facebook, c'est un formulaire et non pas du http basic. Il faudra donc soumettre un formulaire, ca veux dire analyser la page en question pour voir qu'est-ce qui doit être soumis.