Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. final String CONSUMER_KEY = "HHrGLrxxxxxxxxxxxk4jh534j";
  2.  
  3. final String CONSUMER_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  4.  
  5. final String ACCESS_TOKEN = "1588987572-WJOKl3jsRkfxxxxxxxxxxxxx";
  6.  
  7. final String ACCESS_TOKEN_SECRET = "qgioo3BhLTxxxxxxxxxxxxxxxxxx";
  8.  
  9. ConfigurationBuilder builder = new ConfigurationBuilder();
  10. builder.setOAuthConsumerKey(CONSUMER_KEY);
  11. builder.setOAuthConsumerSecret(CONSUMER_SECRET);
  12. Configuration configuration = builder.build();
  13. TwitterFactory factory = new TwitterFactory(configuration);
  14. Twitter twitter = factory.getInstance();
  15. twitter.setOAuthAccessToken(new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET));`
  16.  
  17. JLabel lblUserName = new JLabel("User Name : ");
  18.  
  19. textField = new JTextField();
  20. textField.setColumns(10);
  21.  
  22. JLabel lblPassword = new JLabel("Password : ");
  23.  
  24. passwordField = new JPasswordField();
  25.  
  26. JButton btnLogin = new JButton("Login");
  27. btnLogin.addActionListener(new ActionListener() {
  28. public void actionPerformed(ActionEvent e) {
  29. try{
  30. String userName = textField.getText();
  31. String password = String.valueOf(passwordField.getPassword());
  32. Twitter twitter = new Twitter(userName, password);//there I'm getting this error "Cannot instantiate the type Twitter"
  33. twitter.verifyCredentials();
  34. JOptionPane.showMessageDialog(null, "You're logged in!");
  35. }catch (TwitterException e1) {
  36. JOptionPane.showMessageDialog(null, "Login failed!");
  37. }
  38. }
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement