List of usage examples for twitter4j.conf ConfigurationBuilder setDebugEnabled
public ConfigurationBuilder setDebugEnabled(boolean debugEnabled)
From source file:Origin.Tweet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, TwitterException { response.setContentType("text/html;charset=UTF-8"); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey(CONSUMER_KEY); cb.setOAuthConsumerSecret(CONSUMER_SECRET); cb.setOAuthAccessToken(ACCESS_TOKEN); cb.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET); try {//from ww w .j a v a 2 s .c o m Twitter twitter = new TwitterFactory(cb.build()).getInstance(); User user = twitter.verifyCredentials(); HttpSession session = request.getSession(); request.setCharacterEncoding("UTF-8"); //String tweet = encode(request.getParameter("tweet")); String tweet = request.getParameter("tweet"); Status status = twitter.updateStatus(tweet); session.setAttribute("tweet", tweet); request.getRequestDispatcher("/tweet.jsp").forward(request, response); } catch (TwitterException e1) { e1.printStackTrace(); } }
From source file:project.mum.TwitterTrend.java
public List getTrends(double longi, double lati) throws TwitterException { List availableTrends = new ArrayList<String>(); ConfigurationBuilder cf = new ConfigurationBuilder(); cf.setDebugEnabled(true).setOAuthConsumerKey("TBFU8jBXiIOEde0cnSglw2m7B") .setOAuthConsumerSecret("c0tJVVvGgpY2rI1Ol5qmxzMpB1MiBx8PGlLNPG7TYAAVXwYVvL") .setOAuthAccessToken("1148852892-OR8mM62nOH4WPJf991X5bCp4zVKT2EU57fBmjWQ") .setOAuthAccessTokenSecret("zpXLqUxlkHZT58RDbGEPLnXVB3Kpwp7d8Z4CKb4X4UJW6"); TwitterFactory tf = new TwitterFactory(cf.build()); twitter4j.Twitter twitter = tf.getInstance(); ResponseList<Location> locations; List<MyTrend> myTrend = new ArrayList<MyTrend>(); MyTrend myTwitterTrend;/* w w w . j a v a 2 s . c om*/ GeoLocation geo = new GeoLocation(longi, lati); locations = twitter.getClosestTrends(geo); Trends trends = twitter.getPlaceTrends(locations.get(0).getWoeid()); int count = 0; for (Trend trend : trends.getTrends()) { if (count < 5) { myTwitterTrend = new MyTrend(trend.getName(), trend.getURL()); myTrend.add(myTwitterTrend); count++; availableTrends.add(trend.getName()); } } System.out.println(" available Trends :" + availableTrends); return myTrend; }
From source file:proyectotwitter.AppTwitter.java
public void connect() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("h5QMQS9cq1YDXlgBSZFOoJnkz") .setOAuthConsumerSecret("lCnodmJSIPHVhuxpZlnKe88TQDgwO9OGYCLpdR5gpVdKIiorCb") .setOAuthAccessToken("843739695091802112-z9wPdDceVHCkzQT9xgfUcPyA3scb7b6") .setOAuthAccessTokenSecret("1cygSjbP9gyZ0aGJep8sK2603tcZ6yaILM843nQpHdPaL"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter = tf.getInstance();/*from ww w .jav a 2 s . c o m*/ }
From source file:samples.TwitterSentiment.java
public static twitter4j.Twitter getTwitter() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("sB9TX9gJ9V4nB8Jh8ObKFd2FS") .setOAuthConsumerSecret("RPwx1Zb3DrWpqSA9g5V7GtXeidZES6xL5VnihnveSdREBA6Lgu") .setOAuthAccessToken("767789639843414021-3Svwm5jrJBXUkRLf0f2CAbKwSHLXH9B") .setOAuthAccessTokenSecret("KYUG7JbavSma9oaONPYU0ZIt1leAYFkPut75jBfWHrLTR"); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
From source file:search.TwitterSearchBean.java
@PostConstruct public void init() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("tyyEHDfVKxsBqQWTeWgPkRhZd") .setOAuthConsumerSecret("94MPLfuaVzrWDo6RKc06MnuiJMz1yMkLvcO3wyqd6WtxIpSte0") .setOAuthAccessToken("169980309-qZqlDKT3XSdoki1WBmQFLHANx7QEyGxxm5tEN7gu") .setOAuthAccessTokenSecret("NjVrRzShxNkzyvUD5kn3KcvNvfQrelJXpzfljnSQeq9Ef"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter = tf.getInstance();//from w w w .jav a 2 s. c o m }
From source file:SentimentAnalyses.PrintSampleStream.java
License:Apache License
public static void main(String[] args) throws TwitterException { final PrintSampleStream pr = new PrintSampleStream(); try {/*from www.j av a 2 s .c o m*/ pr.LinkMongodb(); } catch (Exception e) { e.printStackTrace(); } ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("Em3WTI7jc90HcvKzPkTLQ") .setOAuthConsumerSecret("vg4p6rOF32bmffqRR8m0jAUClrxvtGiMB5PrSr3Zsw") .setOAuthAccessToken("1681973072-1q0zI0VPjHD3ttNuaBOL94frzCI9sXInxAcDK0w") .setOAuthAccessTokenSecret("ZRLkOyjmhHBkU1iNyEVNyIgIBsKrl0DUDKOcOMneYFYEM"); cb.setJSONStoreEnabled(true); TwitterStreamFactory tf = new TwitterStreamFactory(cb.build()); TwitterStream twitterStream = tf.getInstance(); StatusListener listener = new StatusListener() { @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); // System.out.println(dbObject); pr.collection.insert(dbObject); //System.out.println(dbObject); pr.count++; if (pr.count % 1000 == 0) System.out.println(pr.count); if (pr.count > 100000) { pr.mongo.close(); System.exit(0); } } catch (Exception e) { e.printStackTrace(); } } @Override public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId()); } @Override public void onTrackLimitationNotice(int numberOfLimitedStatuses) { System.out.println("Got track limitation notice:" + numberOfLimitedStatuses); } @Override public void onScrubGeo(long userId, long upToStatusId) { System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId); } @Override public void onStallWarning(StallWarning warning) { System.out.println("Got stall warning:" + warning); } @Override public void onException(Exception ex) { ex.printStackTrace(); } }; twitterStream.addListener(listener); String[] trackArray; String[] Track = { "Malaysia Airlines", "Flight MH370", "Boeing-777", "Kuala Lumpur", "Bei jing" }; //trackArray[0] = "Obama"; //trackArray[1] = "Romney"; FilterQuery filter = new FilterQuery(); filter.track(Track); String[] lang = { "en" }; filter.language(lang); twitterStream.filter(filter); //pr.mongo.close(); }
From source file:sentimentanalysis.Twitter.Twitter4JConfig.java
public ConfigurationBuilder getConfigurationBuilder() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(CONSUMER_KEY).setOAuthConsumerSecret(CONSUMER_SECRET) .setOAuthAccessToken(ACCESS_KEY).setOAuthAccessTokenSecret(ACCESS_SECRET); return cb;//from w w w . ja v a2 s. c om }
From source file:setting.TwitterToken.java
public static Twitter twitterObject() { Twitter twitter = null;//from ww w . ja v a 2s . c om try { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("Kb8ND2PPNcQoJSEdh2pA") .setOAuthConsumerSecret("vb1tSs2CRUZQUkfKDRCDAEqO1JUpSvBU7vtW3Al52IY") .setOAuthAccessToken("88373110-NaKga9zqHgI3t9gxWxlUQ8od8VakHtHqupLX8BKmS") .setOAuthAccessTokenSecret("vKp9xuT3XQWeCZ3VfgnoAeKmtqaBVB7yjpLxZJmAEgdgX"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter = tf.getInstance(); System.out.println(twitter); } catch (Exception e) { System.out.println(e); } return twitter; }
From source file:setting.TwitterToken.java
public static TwitterFactory getTwitterFactory() { TwitterFactory tf = null;//from w w w .j a v a2 s . co m try { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("Kb8ND2PPNcQoJSEdh2pA") .setOAuthConsumerSecret("vb1tSs2CRUZQUkfKDRCDAEqO1JUpSvBU7vtW3Al52IY") .setOAuthAccessToken("88373110-NaKga9zqHgI3t9gxWxlUQ8od8VakHtHqupLX8BKmS") .setOAuthAccessTokenSecret("vKp9xuT3XQWeCZ3VfgnoAeKmtqaBVB7yjpLxZJmAEgdgX"); tf = new TwitterFactory(cb.build()); } catch (Exception e) { System.err.println(" Exception occure in Twitter getTwitterFactory " + e); } return tf; }
From source file:Situational_Awareness.TwitterSearch.java
public TwitterSearch() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("XQj7G52yevzl0pBkySy3UzvzR") .setOAuthConsumerSecret("yfsTeuPGbbX6pSvIiiOazx2E9vkuoCm1qBYT7Jvek9I5C9BPr3") .setOAuthAccessToken("4713593925-gOovKDZzZ5bmk6hX8CIqwmosVx6EcKQ4uxqoeVD") .setOAuthAccessTokenSecret("43YMSb8LRb6O7Fk0rS5vLSEzGXJ0WUCcPknpG0erSfoLb"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter = tf.getInstance();//from ww w . j a va 2 s.co m }