List of usage examples for twitter4j.conf ConfigurationBuilder setJSONStoreEnabled
public ConfigurationBuilder setJSONStoreEnabled(boolean enabled)
From source file:twitter.signin.java
public void initConfig() { if (System.getenv("OPENSHIFT_APP_NAME") != null) { twitter_consumer_key = "tansiongmmin"; twitter_consumer_secret = "miguelRiigen"; System.out.println("tw33tboard"); } else {/*w ww . ja v a 2 s. c o m*/ System.out.println("localhost"); } ConfigurationBuilder cb = new ConfigurationBuilder(); System.out.println(twitter_consumer_key); cb.setJSONStoreEnabled(true); cb.setDebugEnabled(true).setOAuthConsumerKey(twitter_consumer_key) .setOAuthConsumerSecret(twitter_consumer_secret); tf = new TwitterFactory(cb.build()); twitter = tf.getInstance(); }
From source file:TwitterCrawler.PrintSampleStream.java
License:Apache License
public static void main(String[] args) throws TwitterException { System.getProperties().put("http.proxyHost", "127.0.0.1"); System.getProperties().put("http.proxyPort", "8580"); //final PrintSampleStream pr = new PrintSampleStream(); try {// ww w.jav a 2 s . c o m pr.LinkMongodb(); } catch (Exception e) { e.printStackTrace(); } ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("7ZVgfKiOvBDcDFpytRWSA") .setOAuthConsumerSecret("JmeJVeym78arzmGthrDUshQyhkq6nWA9tWLUKxc") .setOAuthAccessToken("321341780-Zy7LptVYBZBVvAeQ5GFJ4aKFw8sdqhWBnvA3pDuO") .setOAuthAccessTokenSecret("foi8FnQCeN0J5cdwad05Q6d7dbytFayQn1ZOvmhF6Qc"); cb.setJSONStoreEnabled(true); TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); StatusListener listener = new StatusListener() { @Override public void onException(Exception ex) { // TODO Auto-generated method stub ex.printStackTrace(); } @Override public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { // TODO Auto-generated method stub System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId()); } @Override public void onScrubGeo(long userId, long upToStatusId) { // TODO Auto-generated method stub System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId); } @Override public void onStatus(Status status) { //System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); //System.out.println(status); String str = DataObjectFactory.getRawJSON(status); try { //JSONObject nnstr = new JSONObject(newstr); DBObject dbObject = (DBObject) JSON.parse(str); pr.collection.insert(dbObject); System.out.println(dbObject); pr.count++; /* if(pr.count>300000) { pr.mongo.close(); System.exit(0); } */ } catch (Exception e) { e.printStackTrace(); } } @Override public void onTrackLimitationNotice(int numberOfLimitedStatuses) { // TODO Auto-generated method stub System.out.println("Got track limitation notice:" + numberOfLimitedStatuses); } @Override public void onStallWarning(StallWarning arg0) { // TODO Auto-generated method stub } }; twitterStream.addListener(listener); //String[] Track = {"why Obama look like he about to drop the best album of 2013?"}; String[] trackArray = { "Mac", "App", "Store" }; //trackArray[1] = ; // Create a FilterQuery object and then set the items to track FilterQuery filter = new FilterQuery(); // Create an array of items to track //String[] itemsToTrack = {""}; // Set the items to track using FilterQuerys' track method. //filter.track(Track); filter.track(trackArray); // Assuming you have already created Twitter/TwitterStream object, // use the filter method to start streaming using the FilterQuery object just created. twitterStream.filter(filter); /* String[] username = {"katyperry"}; twitterStream.addListener(userlistener); twitterStream.user();*/ //pr.mongo.close(); }
From source file:twittermongodbapp.TwitterMongoDBApp.java
/** * @param args the command line arguments * @throws twitter4j.TwitterException/* w w w . ja va 2s . c o m*/ */ public static void init(ConfigurationBuilder cf) { cf.setDebugEnabled(true); cf.setJSONStoreEnabled(true); cf.setOAuthConsumerKey("SkmxKecZHTxfKmGcQLh7tTufm"); cf.setOAuthConsumerSecret("HPWFJ6jVrVvuCQd4qT1C0b9q3QqifU27mbcuW3M6f8f81IGGQn"); cf.setOAuthAccessToken("719105233322905600-FTnAnBZBFZ4AADDTpNyJNPNidsVNvvv"); cf.setOAuthAccessTokenSecret("D6yIzAKqBLrGLAdIsXk5XvdUehudkgUqO5S7xrWcYp5pu"); }
From source file:uniandes.edu.twitterreader.TwitterApp.java
public TwitterApp() { // Twitter Configuration ConfigurationBuilder cf = new ConfigurationBuilder(); cf.setDebugEnabled(true).setOAuthConsumerKey("Pjh11zSaQp7uI4Qe6HZrnXp5f") .setOAuthConsumerSecret("dCT2Z85JQ0B9FPafVrbEP26cC4dGduMkQeRT29YIU4Mhl8bhk0") .setOAuthAccessToken("105491840-OzLXnQyvNrpfm7pp6X0b6olTDWKKWmxvdhlQnA2a") .setOAuthAccessTokenSecret("edrCvTf2AOo7xIpuBwFNLY5GS0Dbx35KbFygMzs17hvrY"); cf.setJSONStoreEnabled(true); TwitterFactory tf = new TwitterFactory(cf.build()); twitter = tf.getInstance();/* www . j av a 2 s . c o m*/ // Mongo connection mongoDB = new MongoClient(DB_SERVER, DB_PORT).getDatabase(DB_NAME); if (mongoDB.getCollection(COLLECTION_NAME) == null) { mongoDB.createCollection(COLLECTION_NAME); } mongoCollection = mongoDB.getCollection(COLLECTION_NAME); }