List of usage examples for twitter4j.auth AccessToken AccessToken
public AccessToken(String token, String tokenSecret)
From source file:uk.co.cathtanconsulting.twitter.TwitterSource.java
License:Apache License
@Override public void configure(Context context) { String consumerKey = context.getString("consumerKey"); String consumerSecret = context.getString("consumerSecret"); String accessToken = context.getString("accessToken"); String accessTokenSecret = context.getString("accessTokenSecret"); twitterStream = new TwitterStreamFactory().getInstance(); twitterStream.setOAuthConsumer(consumerKey, consumerSecret); twitterStream.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret)); twitterStream.addListener(this); avroDatumWriter = new SpecificDatumWriter<TweetRecord>(TweetRecord.class); reportInterval = context.getInteger("reportInterval", 100); statsInterval = context.getInteger("statsInterval", reportInterval * 10); }
From source file:utils.GetTwitters.java
License:Open Source License
public Iterable<MessageTwitter> getMessages() { List<MessageTwitter> messages = new ArrayList<MessageTwitter>(20); if (LastUpdate.getInstance(compte).isUpdate()) { LOGGER.fine("Les messages twitter sont jour, envoie du contenu de la base de donne"); messages.addAll(MessageTwitter.findByCompte(compte)); } else {//from w w w. j a v a 2 s .com LOGGER.fine("Les messages twitter ne sont pas jour, rcupration du contenu de twiter"); Twitter twitter = getFactory().getInstance(); twitter.setOAuthConsumer("9Jsib4k1uEMCWZqEHy1t1Q", "vLQQaog60gYRrPCC2bHeEZdod3JDSkTRI9W7r2cZIZ8"); twitter.setOAuthAccessToken(new AccessToken("225864007-Y11ZtDLq2LVZwMR3anKxPW9nR6dIGkLyFlOhdAMx", "GQ16L9QMhhzSiRT4xRia7B25011BoNsXUEgUyp0vKI")); ResponseList<Status> listeStatus; try { listeStatus = twitter.getUserTimeline("@" + compte); } catch (TwitterException e) { LOGGER.log(Level.SEVERE, "Erreur lors de l'accs twitter", e); return MessageTwitter.findByCompte(compte); } for (Status status : listeStatus) { messages.add(new MessageTwitter(status.getCreatedAt(), status.getText(), compte)); } MessageTwitter.deleteAll(); for (MessageTwitter message : messages) { message.save(); } } Collections.sort(messages, new Comparator<MessageTwitter>() { public int compare(MessageTwitter o1, MessageTwitter o2) { return o2.getDateCreation().compareTo(o1.getDateCreation()); } }); return messages; }
From source file:View.TweetController.java
/** * Initializes the controller class./*w ww . j a v a 2 s. co m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { //create twitter object twitter = new TwitterFactory().getInstance(); //used specifically for the application (this verifies the application with twitter) twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); //my (the users) specific access information which will persist in a database once production ready twitter.setOAuthAccessToken(new AccessToken("192799309-khPEsofCf90vu5ejWG3zAKOlhcuyszg8l0MC4YEg", "1kMLko3zzQMyDwpZ8hC5oqRZQ5KqwQhCgYUy5cZSZROCM")); //the users timeline timeLine = new VBox(); timelineBtn.setSelected(true); //give the timeline a scrollpane scrollPane.setContent(timeLine); //users profile profile = new VBox(); //users settings settings = new VBox(); //set the action for the tweet button tweetBtn.setOnAction(e -> { try { postTweet(); } catch (TwitterException ex) { } catch (MalformedURLException ex) { Logger.getLogger(TweetController.class.getName()).log(Level.SEVERE, null, ex); } }); //any text that is too long for the line is sent to next line commentBox.setWrapText(true); }