List of usage examples for twitter4j.conf ConfigurationBuilder setDebugEnabled
public ConfigurationBuilder setDebugEnabled(boolean debugEnabled)
From source file:entities.TwitterFeed.java
public void initTimeline() { timelineFrame = new JFrame("@SIM_IST Timeline"); timelineFrame.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); timelineBack = new JButton("Back"); timelineBack.addActionListener(this); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5;/*from w ww. jav a 2s .co m*/ c.gridx = 1; c.gridy = 1; c.gridwidth = 1; timelineFrame.add(timelineBack, c); timelineTweets = new JTextArea(); Font font = new Font("Gotham Narrow", Font.BOLD, 12); timelineTweets.setFont(font); timelineTweets.setEditable(false); timelineScrollPane = new JScrollPane(timelineTweets); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.ipady = 200; c.gridx = 0; c.gridy = 0; c.gridwidth = 3; timelineFrame.add(timelineScrollPane, c); KeyReader keys = new KeyReader(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(keys.getConsumerKey()) .setOAuthConsumerSecret(keys.getConsumerSecret()).setOAuthAccessToken(keys.getAccessToken()) .setOAuthAccessTokenSecret(keys.getAccessTokenSecret()); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); try { System.out.println("timeline retreval worked"); List<Status> statuses = twitter.getHomeTimeline(); for (Status status : statuses) { timelineTweets .append("@" + status.getUser().getScreenName() + " : " + status.getText() + "\n" + "\n"); timelineTweets.setLineWrap(true); timelineTweets.setWrapStyleWord(true); timelineTweets.setCaretPosition(0); System.out.println("@" + status.getUser().getName() + " : " + status.getText()); } } catch (TwitterException te) { System.out.print("timeline retreval failed"); te.printStackTrace(); } timelineFrame.pack(); timelineFrame.setSize(600, 300); timelineFrame.setDefaultCloseOperation(EXIT_ON_CLOSE); timelineFrame.setLocationRelativeTo(null); timelineFrame.setVisible(true); }
From source file:erando.controllers.AddProductController.java
@FXML private void addProductAction(ActionEvent event) throws FileNotFoundException, IOException, TwitterException, DocumentException { Product p = new Product(); Sms sms = new Sms(); ISms smsservice = new SmsService(); IShopService productService = new ProductService(); Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("YYYY:MM/HH:mm:ss"); p.setTitre(pTitre.getText());/*from w ww. j a v a 2 s. c o m*/ p.setPrix(Integer.parseInt(pPrix.getText())); p.setDescription(pDescription.getText()); p.setType(pType.getValue().toString()); p.setDate(sdf.format(cal.getTime())); p.setImage(imageName); if (!pTitre.getText().isEmpty() && !pPrix.getText().isEmpty() && !pDescription.getText().isEmpty() && !pType.getValue().toString().isEmpty()) { productService.add(p); ////////send sms to subs sms.setNum("" + Parameters.user.getNumTel()); sms.setMessagetel("Product Added To Store go check it !"); smsservice.sendSms(sms); ////////share on facebook (when asked by the owner ! ) if (shareFacebook.isSelected()) { String accessToken = "EAACEdEose0cBAKLtkZBKZCBoEkx4MApf3HxDMAR93PoJ6lAAuZAMdfY9vtob2ii78C6TN88hSV8HK0tDZBskaUz5pcbH1HqVeDRISuEHsG0qqUZBca4gHGnANPWcZBSZA9RNFHpbwVHJ46ITntn52SGQWetPPaZBsNlsFXbpcDrKytOVtmspQzfrM8GiUQtm1kQZD"; FacebookClient fbClient = new DefaultFacebookClient(accessToken, Version.LATEST); File fs = new File("C:\\Users\\F.Mouhamed\\Desktop\\Esprit\\ERandoPi\\userfiles\\"); fs.getParentFile().setExecutable(true); fs.getParentFile().setReadable(true); fs.getParentFile().setWritable(true); ////////FileInputStream fis = new FileInputStream(fs.getParentFile()); User me = fbClient.fetchObject("me", User.class); FacebookType response; response = fbClient.publish("me/feed", FacebookType.class, Parameter.with("message", p.getTitre() + "\n " + p.getDescription() + "\n Prix:" + p.getPrix())); } ////////share on twitter (when asked by the owner ! ) if (shareTwitter.isSelected()) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("dHU6c4cXI6HDeLI3pakG8PYtp") .setOAuthConsumerSecret("n0NxZVXgpEMGJboWYBSD1nfbaa3Ov2qL0e9h2GzyUsa8wQ0q0p") .setOAuthAccessToken("729655065716346881-gukmKiOsT5WFv05t3yfQFrWgoPycQGD") .setOAuthAccessTokenSecret("4qTGW5YdG8j9biJeAybzIcivCPZaAOqES2PhoJI9S7WKL"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter4j.Twitter tw = tf.getInstance(); String StatusMessage = ("Titre :" + p.getTitre() + "\nDescription:\n" + p.getDescription() + "\nPrix:" + p.getPrix()); StatusUpdate status = new StatusUpdate(StatusMessage); tw.updateStatus(status); } /////////show notification Notifications notificationBuilder = Notifications.create().title("sucess").text("produit ajouter") .graphic(null).hideAfter(Duration.seconds(4)).position(Pos.BOTTOM_RIGHT); notificationBuilder.darkStyle(); notificationBuilder.showConfirm(); /////////send emails to users subscribed to this type of product List<String> subs = productService.getSubscribes(p.getType()); mailToSubs mails = new mailToSubs(); for (String s : subs) { mails.envoyerfacture(s.toString(), p.getImage().toString(), p.getId(), p.getTitre(), p.getPrix(), p.getDescription()); } } }
From source file:examencodtwitter.Metodos.java
/** /*from ww w .j a v a 2s . com*/ */ public Metodos() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("xxxxxxxxxx").setOAuthConsumerSecret("xxxxxxxxxxxxxxxxxxxxxx") .setOAuthAccessToken("xxxxxxxxxxxxxxxxxxxxxx") .setOAuthAccessTokenSecret("xxxxxxxxxxxxxxxxxxxxxxxxxx"); twitter = new TwitterFactory(cb.build()).getInstance(); }
From source file:examendetwitter.metodostwitter.java
/** * Constructor, da acceso a nuestra cuenta en twitter. *//*from w w w.j a v a2s . c om*/ public metodostwitter() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("ttn86DHjTWZ21heKN6uQp9iy6") .setOAuthConsumerSecret("wQagAbytgoScb8UtCwY5nupQJkmW844MNrpMTVuQMFytxmceuP") .setOAuthAccessToken("3318200759-FsPeZSPibyDHgiPk7KllUBmvN5LarHeFpjH3JSv") .setOAuthAccessTokenSecret("z5I7uNEiIZH0ni9iNhKyUtASnHnGXN6puxjfQi6476RF0"); twitter = new TwitterFactory(cb.build()).getInstance(); twitter = new TwitterFactory("twitter4j.properties").getInstance(); }
From source file:flight_ranker.Flight_colllector.java
public static void main(String[] args) throws FileNotFoundException, IOException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey("Oa6WAzH0j3sgVrP0CNGvxnWA2"); cb.setOAuthConsumerSecret("sLdoFybvJvVFz7Lxbbv9KWQDFeKcVeZAkWDC4QMHnx5lV2OmGE"); cb.setOAuthAccessToken("2691889945-5NOBWKUgT9FiAoyOQSCFg8CLlPRlDMbWcUrJBdK"); cb.setOAuthAccessTokenSecret("J6tA8Sxrtz2JNSFdQwAonbGxNfLNuD9I54Zfvomku3p5t"); TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); StatusListener listener = new StatusListener() { @Override/*from w w w. j a va2s . c om*/ public void onException(Exception arg0) { // TODO Auto-generated method stub } @Override public void onDeletionNotice(StatusDeletionNotice arg0) { // TODO Auto-generated method stub } @Override public void onScrubGeo(long arg0, long arg1) { // TODO Auto-generated method stub } @Override public void onStatus(Status status) { User user = status.getUser(); // gets Username String username = status.getUser().getScreenName(); long followers = user.getFollowersCount(); long retweets = status.getRetweetCount(); long favs = status.getFavoriteCount(); System.out.println("USERNAME--> " + username); System.out.println("FOLLOWERS--> " + followers); String profileLocation = user.getLocation(); // System.out.println("RETWEETS--> "+retweets); // System.out.println("FAVOURITES--> "+favs); System.out.println("LOCATION--> " + profileLocation); long tweetId = status.getId(); System.out.println("TWEET ID--> " + tweetId); String content = status.getText(); System.out.println("TWEET--> " + content + "\n"); BufferedWriter b1 = null, b2, b3, b4, b5, b6, b7 = null; try { //output_file = new BufferedReader(new FileReader("G:\\Sentiwords.txt")); FileWriter f1 = new FileWriter("G:\\flights_data.txt", true); b1 = new BufferedWriter(f1); b1.write("#USERNAME- " + username); b1.newLine(); b1.write("#Followers- " + followers); b1.newLine(); b1.write("#Location- " + profileLocation); b1.newLine(); b1.write("#ID- " + tweetId); b1.newLine(); b1.write("#Tweet- " + content); b1.newLine(); b1.newLine(); tweet_editor modified_tweet = new tweet_editor(content); //tweet_tagger tagged_tweet = new tweet_tagger(modified_tweet.edited_tweet); //System.out.println(tagged_tweet.tagged); sentiment_calculator senti_value = new sentiment_calculator(modified_tweet.edited_tweet); if (content.contains("Indigo")) { System.out.println("indigo"); FileWriter f2 = new FileWriter("G:\\Indigo.txt", true); b2 = new BufferedWriter(f2); b2.write(Double.toString(senti_value.senti_rate)); b2.newLine(); } if (content.contains("Jet")) { System.out.println("jet"); FileWriter f3 = new FileWriter("G:\\jet.txt", true); b3 = new BufferedWriter(f3); b3.write(Double.toString(senti_value.senti_rate)); b3.newLine(); } if (content.contains("Indian")) { System.out.println("indian"); FileWriter f4 = new FileWriter("G:\\Indian.txt", true); b4 = new BufferedWriter(f4); b4.write(Double.toString(senti_value.senti_rate)); b4.newLine(); } if (content.contains("Spicejet")) { System.out.println("spicejet"); FileWriter f5 = new FileWriter("G:\\spicejet.txt", true); b5 = new BufferedWriter(f5); b5.write(Double.toString(senti_value.senti_rate)); b5.newLine(); } if (content.contains("AirAsia")) { System.out.println("airasia"); FileWriter f6 = new FileWriter("G:\\airasia.txt", true); b6 = new BufferedWriter(f6); b6.write(Double.toString(senti_value.senti_rate)); b6.newLine(); } try { //output_file = new BufferedReader(new FileReader("G:\\Sentiwords.txt")); FileWriter f7 = new FileWriter("G:\\flight_senti.txt", true); b7 = new BufferedWriter(f7); b7.write(String.valueOf(senti_value.senti_rate)); b7.newLine(); } catch (IOException e) { e.printStackTrace(); } finally { try { b7.close(); } catch (IOException ex) { Logger.getLogger(Flight_colllector.class.getName()).log(Level.SEVERE, null, ex); } } } catch (IOException e) { e.printStackTrace(); } finally { try { b1.close(); } catch (IOException ex) { Logger.getLogger(Flight_colllector.class.getName()).log(Level.SEVERE, null, ex); } } } @Override public void onTrackLimitationNotice(int arg0) { // TODO Auto-generated method stub } @Override public void onStallWarning(StallWarning sw) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; FilterQuery fq = new FilterQuery(); String keywords[] = { "Indian Airlines, Indigo Airlines, Indigo Airline , Indian Airline , Spicejet , jetAirways , Jet Airways, Jet Airlines , airasia" }; //we will pass stock related keyword here fq.track(keywords); twitterStream.addListener(listener); twitterStream.filter(fq); }
From source file:formel0api.Game.java
License:Open Source License
private void sendHighScoreToServer() { try {//from ww w.jav a2s. com String now = this.javaDate2XmlDate(new Date()).toString(); StringBuffer xmlStr = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<highScoreRequestType \n" + " xmlns=\"http://big.tuwien.ac.at/we/highscore/data\" \n" + " xmlns:ssd=\"http://www.dbai.tuwien.ac.at/education/ssd/SS13/uebung/Tournament\">\n" + "\n" + " <UserKey>34EphAp2C4ebaswu</UserKey>\n" + " <ssd:tournament start-date=\"" + now + "\" end-date=\"" + now + "\" registration-deadline=\"" + now + "\">\n" + " <ssd:players>\n" + " <ssd:player username=\"" + this.getLeaderData().getName() + "\">\n" + " <ssd:date-of-birth>" + this.getFormattedDate(this.getLeaderData().getBirthday()) + "</ssd:date-of-birth>\n" + " <ssd:gender>" + this.getLeaderData().getSex() + "</ssd:gender>\n" + " </ssd:player>\n" + " </ssd:players>\n" + " <ssd:rounds>\n" + " <ssd:round number=\"0\">\n" + " <ssd:game date=\"" + now + "\" status=\"finished\" duration=\"" + this.getSpentTime() + "\" winner=\"" + this.getLeaderData().getName() + "\">\n" + " <ssd:players>\n" + " <ssd:player ref=\"" + this.getLeaderData().getName() + "\"/>\n" + " </ssd:players>\n" + " </ssd:game>\n" + " </ssd:round>\n" + " </ssd:rounds>\n" + " </ssd:tournament>\n" + "</highScoreRequestType>"); JAXBContext jaxbContext = JAXBContext.newInstance(HighScoreRequestType.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); HighScoreRequestType request = (HighScoreRequestType) jaxbUnmarshaller .unmarshal(new StreamSource(new StringReader(xmlStr.toString()))); PublishHighScoreService service = new PublishHighScoreService(); PublishHighScoreEndpoint endpoint = service.getPublishHighScorePort(); String uuid = endpoint.publishHighScore(request); Logger.getLogger(Game.class.getName()).log(Level.INFO, uuid); TwitterStatusMessage tmsg = new TwitterStatusMessage(this.getLeader().getName(), uuid, new Date()); (new ITwitterClient() { @Override public void publishUuid(TwitterStatusMessage message) throws Exception { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("GZ6tiy1XyB9W0P4xEJudQ") .setOAuthConsumerSecret("gaJDlW0vf7en46JwHAOkZsTHvtAiZ3QUd2mD1x26J9w") .setOAuthAccessToken("1366513208-MutXEbBMAVOwrbFmZtj1r4Ih2vcoHGHE2207002") .setOAuthAccessTokenSecret("RMPWOePlus3xtURWRVnv1TgrjTyK7Zk33evp4KKyA"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); twitter.updateStatus(message.toString()); } }).publishUuid(tmsg); message = "UUID " + uuid + " wurde auf Twitter verffentlicht"; } catch (JAXBException e) { Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, e); } catch (Failure e) { Logger.getLogger(Game.class.getName()).log(Level.SEVERE, e.getFaultInfo().getDetail()); } catch (Exception ex) { Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fr.istic.taa.jaxrs.StatusEndpoint.java
License:Apache License
@GET @Path("/postTweet") @Produces(MediaType.APPLICATION_JSON)//from ww w .j a va 2 s . c om public String getTweet() throws IOException, TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("jUTzyyI3zjBqiKQqhfQyFeqpm") .setOAuthConsumerSecret("gMkOSO9EYqlzrnq35kdoZIqvX12sJwP1wHKMqo6uYbvq2q0LGl") .setOAuthAccessToken("89767958-C2cLIz69SpdR6wmQGdzE8rQSXAMzIVBpYOuaZGmHQ") .setOAuthAccessTokenSecret("oG7FQJMQsX2OHKxcaHjUxgZI94ZqUShGi0qCAsI50xfpZ"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); String latestStatus = "TEST55555555"; Status status = twitter.updateStatus(latestStatus); System.out.println("Successfully updated the status to [" + status.getText() + "]."); return "Successfully updated status to " + status.getText(); }
From source file:fr.istic.taa.jaxrs.StatusEndpoint.java
License:Apache License
@GET @Path("/sendTweet") @Produces(MediaType.APPLICATION_JSON)/* w ww .j a v a2s . c o m*/ public String sendTweet() throws IOException, TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("jUTzyyI3zjBqiKQqhfQyFeqpm") .setOAuthConsumerSecret("gMkOSO9EYqlzrnq35kdoZIqvX12sJwP1wHKMqo6uYbvq2q0LGl") .setOAuthAccessToken("89767958-C2cLIz69SpdR6wmQGdzE8rQSXAMzIVBpYOuaZGmHQ") .setOAuthAccessTokenSecret("oG7FQJMQsX2OHKxcaHjUxgZI94ZqUShGi0qCAsI50xfpZ"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); String recipientId; recipientId = "@nassssssiim"; String message; message = "test"; DirectMessage message1 = twitter.sendDirectMessage(recipientId, message); System.out.println(" to @" + message1.getRecipientScreenName()); return " to @" + message1.getRecipientScreenName(); }
From source file:io.warp10.script.functions.TWITTERDM.java
License:Apache License
@Override public Object apply(WarpScriptStack stack) throws WarpScriptException { ///*from w w w.j a va 2s. c o m*/ // Extract parameters // String text = stack.pop().toString(); String recipient = stack.pop().toString(); String accessSecret = stack.pop().toString(); String accessToken = stack.pop().toString(); String consumerSecret = stack.pop().toString(); String consumerKey = stack.pop().toString(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessSecret); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); try { twitter.sendDirectMessage(recipient, text); } catch (TwitterException te) { throw new WarpScriptException("Error while sending Twitter Direct Message", te); } return stack; }
From source file:jp.xxxxxxxx.l3fish.twnyaan.service.AuthenticationService.java
License:Open Source License
/** * RequestToken????URL???????PIN???//from ww w . j a v a 2 s.c o m * RequestToken??????{@code null}? * * @return ???RequestToken??????????{@code null} */ public RequestToken authorize() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(TwitterAPIKey.getConsumerKey()) .setOAuthConsumerSecret(TwitterAPIKey.getConsumerSecret()); Twitter twitter = new TwitterFactory(cb.build()).getInstance(); RequestToken requestToken = null; try { requestToken = twitter.getOAuthRequestToken(); URI authorizationURI = new URI(requestToken.getAuthorizationURL()); Desktop desktop = Desktop.getDesktop(); desktop.browse(authorizationURI); } catch (URISyntaxException | IOException e) { System.err.println(ErrorCode.CANNOT_OPEN_AUTHORIZATION_URI); } catch (TwitterException e) { System.err.println(ErrorCode.TWITTER_SERVICE_UNAVAILABLE); } return requestToken; }