Connection to Twitter

1

I would like to know what the code fails, it tells me that "Can not instantiate the Twitter type" where I instancio a Twitter object, Work with the twitter4j library.

import java.util.List;    
import twitter4j.*;
import twitter4j.Twitter;
public class twitterMain {

    public static void main(String[] args) {


        try {
            Twitter twitter = new Twitter("XXXXXXX","YYYYYYYY");
          } catch (TwitterException ex) {             
            System.out.println("Error: "+ex.getMessage());   
          }    

    }

}
    
asked by FastMaster 10.01.2017 в 00:13
source

1 answer

1

To instantiate it must be

           try {
           //Twitter twitter = new Twitter("XXXXXXX","YYYYYYYY");
           Twitter twitter = new TwitterFactory().getInstance();
           twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");

          } catch (TwitterException ex) {             
            System.out.println("Error: "+ex.getMessage());   
          }    

You can see it in the Twitter4j documentation: link

    
answered by 10.01.2017 в 00:30