List of usage examples for twitter4j.auth AuthorizationFactory getInstance
public static Authorization getInstance(Configuration conf)
From source file:cmu.edu.homework.mediaUpload.PhotoUploadFactory.java
License:Apache License
/** * Returns an PhotoUploader instance associated with the specified media provider * * @param mediaProvider media provider/* ww w.j a v a 2s . c om*/ * @return PhotoUploader */ public PhotoUpload getInstance(MediaProvider mediaProvider) { Authorization authorization = AuthorizationFactory.getInstance(conf); OAuthAuthorization oauth = (OAuthAuthorization) authorization; return getInstance(mediaProvider, authorization); }
From source file:cmu.edu.homework.mediaUpload.VideoUploadFactory.java
License:Apache License
/** * Returns an VideoUploader instance associated with the specified media provider * * @param mediaProvider media provider// ww w . j av a 2 s . c om * @return VideoUploader */ public VideoUpload getInstance(MediaProvider mediaProvider) { Authorization authorization = AuthorizationFactory.getInstance(conf); OAuthAuthorization oauth = (OAuthAuthorization) authorization; return getInstance(mediaProvider, authorization); }
From source file:org.rhq.plugins.twitter.TwitterComponent.java
License:Open Source License
private Twitter createTwitterInstance() { Properties props = new Properties(); props.setProperty(PropertyConfiguration.USER, username); props.setProperty(PropertyConfiguration.PASSWORD, password); PropertyConfiguration propConfig = new PropertyConfiguration(props); return tFactory.getInstance(AuthorizationFactory.getInstance(propConfig)); }
From source file:org.taverna.server.master.notification.TwitterDispatcher.java
private Twitter getTwitter(String key, String secret) throws Exception { if (key.isEmpty() || secret.isEmpty()) throw new NoCredentialsException(); Properties p = getConfig();//from ww w .java 2s. c om p.setProperty(OAUTH_CONSUMER_KEY, key); p.setProperty(OAUTH_CONSUMER_SECRET, secret); Configuration config = new PropertyConfiguration(p); TwitterFactory factory = new TwitterFactory(config); Twitter t = factory.getInstance(AuthorizationFactory.getInstance(config)); // Verify that we can connect! t.getOAuthAccessToken(); return t; }
From source file:org.uma.jmetalsp.application.biobjectivetsp.sparkutil.StreamingConfigurationTSP.java
License:Open Source License
/** * Create Twitter configuration/*from w ww. j a v a 2 s .c om*/ * @param consumerKey * @param consumerSecret * @param accessToken * @param accessTokenSecret * @param proxyHost * @param proxyPort * @param twitterFilter */ public void initializeTwitter(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, String proxyHost, int proxyPort, String twitterFilter) { this.twitterFilter = twitterFilter; ConfigurationBuilder cb = new ConfigurationBuilder(); if (proxyHost != null) { System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", String.valueOf(proxyPort)); System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", String.valueOf(proxyPort)); } cb.setDebugEnabled(true).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret); Configuration twitterConf = cb.build(); twitterAuth = AuthorizationFactory.getInstance(twitterConf); }
From source file:uk.co.flax.ukmp.twitter.PartyListHandler.java
License:Apache License
public void refreshLists() { Map<String, Set<Long>> memberIds = new HashMap<>(); Authorization auth = AuthorizationFactory.getInstance(twitterConfig); TwitterFactory tf = new TwitterFactory(twitterConfig); Twitter twitter = tf.getInstance(auth); for (PartyConfiguration pc : parties.values()) { Set<Long> ids = readPartyIds(twitter, pc.getTwitterScreenName(), pc.getTwitterListSlug(), pc.getDisplayName());//from w ww .j av a 2s . c o m if (!ids.isEmpty()) { memberIds.put(pc.getDisplayName(), ids); } } synchronized (partyMemberIds) { for (String party : memberIds.keySet()) { if (!partyMemberIds.containsKey(party) || Sets.symmetricDifference(memberIds.get(party), partyMemberIds.get(party)).size() > 0) { hasChanged = true; partyMemberIds.put(party, memberIds.get(party)); LOGGER.debug("Updated list for {} with {} ids", party, memberIds.get(party).size()); } } } if (hasChanged) { updateTime = new Date(); memberParties.clear(); } }