Bonjour,

Je souhaite faire une application USSD Twitter en Java et pour cela j'utilise la librairie twitter4j.

Je parviens à me connecter à mon compte Twitter à partir de mon application grâce aux clés et tokens et non pas en entrant mon email et mon de passe du compte Twitter (j'ai créé l'application en tant que développeur et j'ai les clés et les tokens).

Cependant je souhaite que n'importe quel utilisateur, en entrant son email et son mot de passe de son compte Twitter dans mon application, parvienne à se connecter à son propre compte.

Dans ce lien http://twitter4j.org/en/code-examples.html il y a ça:
Initially, you don't have a permission to access the user's account and need to acquire access token by redirecting the user to an authorization URL as follows:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
public static void main(String args[]) throws Exception{
    // The factory instance is re-useable and thread safe.
    Twitter twitter = TwitterFactory.getSingleton();
    twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
    RequestToken requestToken = twitter.getOAuthRequestToken();
    AccessToken accessToken = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    while (null == accessToken) {
      System.out.println("Open the following URL and grant access to your account:");
      System.out.println(requestToken.getAuthorizationURL());
      System.out.print("Enter the PIN(if aviailable) or just hit enter.[PIN]:");
      String pin = br.readLine();
      try{
         if(pin.length() > 0){
           accessToken = twitter.getOAuthAccessToken(requestToken, pin);
         }else{
           accessToken = twitter.getOAuthAccessToken();
         }
      } catch (TwitterException te) {
        if(401 == te.getStatusCode()){
          System.out.println("Unable to get the access token.");
        }else{
          te.printStackTrace();
        }
      }
    }
    //persist to the accessToken for future reference.
    storeAccessToken(twitter.verifyCredentials().getId() , accessToken);
    Status status = twitter.updateStatus(args[0]);
    System.out.println("Successfully updated the status to [" + status.getText() + "].");
    System.exit(0);
  }
  private static void storeAccessToken(int useId, AccessToken accessToken){
    //store accessToken.getToken()
    //store accessToken.getTokenSecret()
  }
After you acquired the AccessToken for the user, the RequestToken is not required anymore. You can persist the AccessToken to any kind of persistent store such as RDBMS, or File system by serializing the object, or by geting the token and the secret from AccessToken#getToken() and AccessToken#getTokenSecret().
  public static void main(String args[]) throws Exception{
    // The factory instance is re-useable and thread safe.
    TwitterFactory factory = new TwitterFactory();
    AccessToken accessToken = loadAccessToken(Integer.parseInt(args[0]));
    Twitter twitter = factory.getInstance();
    twitter.setOAuthConsumerKey("[consumer key]", "[consumer secret]");
    twitter.setOAuthAccessToken(accessToken);
    Status status = twitter.updateStatus(args[1]);
    System.out.println("Successfully updated the status to [" + status.getText() + "].");
    System.exit(0);
  }
  private static AccessToken loadAccessToken(int useId){
    String token = // load from a persistent store
    String tokenSecret = // load from a persistent store
    return new AccessToken(token, tokenSecret);
  }
Quelqu'un saurait-il me dire si c'est bien ce que je dois écrire comme solution à mon problème ? Et si c'est ça est-ce que je dois uniquement remplacer et mettre mes propres clés et ça fonctionnera ?

Si vous avez aussi quelques liens ou tutoriels concernant ce problème, n'hésitez pas à m'en faire part.

J'utilise Eclipse.

Merci d'avance pour votre aide.