twitter4j.conf.ConfigurationBuilder Java Examples
The following examples show how to use
twitter4j.conf.ConfigurationBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TwitterOAuthActivity.java From firebase-login-demo-android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setup twitter client mTwitter = new TwitterFactory(new ConfigurationBuilder() .setOAuthConsumerKey(getResources().getString(R.string.twitter_consumer_key)) .setOAuthConsumerSecret(getResources().getString(R.string.twitter_consumer_secret)) .build()).getInstance(); // setup twitter webview mTwitterView = new WebView(this); mTwitterView.getSettings().setJavaScriptEnabled(true); // initialize view setContentView(mTwitterView); // start the web view loginToTwitter(); }
Example #2
Source File: PlayConfigurationView.java From beatoraja with GNU General Public License v3.0 | 6 votes |
@FXML public void startTwitterAuth() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey(txtTwitterConsumerKey.getText()); cb.setOAuthConsumerSecret(txtTwitterConsumerSecret.getText()); cb.setOAuthAccessToken(null); cb.setOAuthAccessTokenSecret(null); TwitterFactory twitterfactory = new TwitterFactory(cb.build()); Twitter twitter = twitterfactory.getInstance(); try { requestToken = twitter.getOAuthRequestToken(); Desktop desktop = Desktop.getDesktop(); URI uri = new URI(requestToken.getAuthorizationURL()); desktop.browse(uri); player.setTwitterConsumerKey(txtTwitterConsumerKey.getText()); player.setTwitterConsumerSecret(txtTwitterConsumerSecret.getText()); player.setTwitterAccessToken(""); player.setTwitterAccessTokenSecret(""); txtTwitterPIN.setDisable(false); twitterPINButton.setDisable(false); txtTwitterAuthenticated.setVisible(false); } catch (Exception e) { e.printStackTrace(); } }
Example #3
Source File: Twitter.java From jacamo with GNU Lesser General Public License v3.0 | 6 votes |
/** * Instantiate a twitter artifact configured with a consumer * key/secret and an access token/secret got for accessing * a Twitter account- */ void init(String consumerKey, String consumerSecret, String accessToken, String accessSecret) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(consumerKey) .setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken) .setOAuthAccessTokenSecret(accessSecret); factory = new TwitterFactory(cb.build()); twitter = factory.getInstance(); try { List<Status> statuses = twitter.getHomeTimeline(); defineObsProperty("tw_user_status",statuses.get(0).getText()); } catch (Exception ex){ ex.printStackTrace(); defineObsProperty("tw_user_status",""); } }
Example #4
Source File: PlayConfigurationView.java From beatoraja with GNU General Public License v3.0 | 6 votes |
@FXML public void startPINAuth() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey(player.getTwitterConsumerKey()); cb.setOAuthConsumerSecret(player.getTwitterConsumerSecret()); cb.setOAuthAccessToken(null); cb.setOAuthAccessTokenSecret(null); TwitterFactory twitterfactory = new TwitterFactory(cb.build()); Twitter twitter = twitterfactory.getInstance(); try { AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, txtTwitterPIN.getText()); player.setTwitterAccessToken(accessToken.getToken()); player.setTwitterAccessTokenSecret(accessToken.getTokenSecret()); commit(); update(config); } catch (TwitterException e) { e.printStackTrace(); } }
Example #5
Source File: TweetLaunchpad.java From The-NOC-List with Apache License 2.0 | 6 votes |
public Twitter getTwitter() throws TwitterException, IOException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(CONSUMER_KEY) .setOAuthConsumerSecret(CONSUMER_KEY_SECRET); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); twitter.setOAuthAccessToken(new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)); return twitter; }
Example #6
Source File: TweetSearcher.java From The-NOC-List with Apache License 2.0 | 6 votes |
public Twitter getTwitter() throws TwitterException, IOException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(CONSUMER_KEY) .setOAuthConsumerSecret(CONSUMER_SECRET) .setOAuthAccessToken(ACCESS_TOKEN) .setOAuthAccessTokenSecret(ACCESS_SECRET); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); twitter.setOAuthAccessToken(new AccessToken(ACCESS_TOKEN, ACCESS_SECRET)); return twitter; }
Example #7
Source File: TwitterNotifier.java From yfiton with Apache License 2.0 | 6 votes |
public TwitterNotifier() throws NotificationException { super(CLIENT_ID, SECRET_ID, PromptReceiver.class, "com.yfiton.notifiers.twitter.TwitterWebEngineListener"); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder .setGZIPEnabled(true) .setDebugEnabled(true) .setOAuthConsumerKey(getClientId()) .setOAuthConsumerSecret(getClientSecret()); com.yfiton.notifiers.twitter.AccessToken accessToken = getAccessToken(); if (accessToken != null) { configurationBuilder.setOAuthAccessToken(accessToken.getAccessToken()); configurationBuilder.setOAuthAccessTokenSecret(accessToken.getAccessTokenSecret()); } twitter = new TwitterFactory( configurationBuilder.build()).getInstance(); }
Example #8
Source File: TwitterAuth.java From liberty-bikes with Eclipse Public License 1.0 | 6 votes |
@GET public Response getTwitterAuthURL(@Context HttpServletRequest request) { ConfigurationBuilder c = new ConfigurationBuilder() .setOAuthConsumerKey(config.twitter_key) .setOAuthConsumerSecret(config.twitter_secret); Twitter twitter = new TwitterFactory(c.build()).getInstance(); request.getSession().setAttribute("twitter", twitter); try { String callbackURL = config.authUrl + "/TwitterCallback"; RequestToken token = twitter.getOAuthRequestToken(callbackURL); request.getSession().setAttribute("twitter_token", token); // send the user to Twitter to be authenticated String authorizationUrl = token.getAuthenticationURL(); return Response.temporaryRedirect(new URI(authorizationUrl)).build(); } catch (Exception e) { e.printStackTrace(); return Response.status(500).build(); } }
Example #9
Source File: TweetEmitter.java From storm-example with Apache License 2.0 | 6 votes |
public TweetEmitter() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("DJSv02qbCiCVY6Sy8uz8Cg") .setOAuthConsumerSecret("iVa3GGSl9NrHvu3AAXm6zBV7Z2XTvtuDkAMiArHlGM") .setOAuthAccessToken("1353264175-5EWRtEHoaJ6zfmAG5BEn7Uc7E8qg7P531oddm08") .setOAuthAccessTokenSecret("ss7YCprReDBEpm4AGnguqB1xNCUwyRGli5Q33yImf0"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter = tf.getInstance(); query = new Query(SEARCH_PHRASE); query.setLang("en"); long now = System.currentTimeMillis(); if (now - lastFetch > FETCH_PERIODICITY) { try { result = twitter.search(query); } catch (TwitterException e) { throw new RuntimeException(e); } } }
Example #10
Source File: DatasetFeaturesExtractor.java From image-verification-corpus with Apache License 2.0 | 6 votes |
/** * Creates the connection to Twitter API. * @return Twitter object for the current connection */ public static Twitter connectToTwitterAPI() { ConfigurationBuilder cb = new ConfigurationBuilder(); /*please fill in your credentials*/ cb.setDebugEnabled(true).setOAuthConsumerKey("CONSUMER_KEY") .setOAuthConsumerSecret("CONSUMER_SECRET") .setOAuthAccessToken("ACCESS_TOKEN") .setOAuthAccessTokenSecret("ACCESS_TOKEN_SECRET"); cb.setJSONStoreEnabled(true); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); return twitter; }
Example #11
Source File: TwitterConnector.java From OSTMap with Apache License 2.0 | 6 votes |
/** * Connects to Twitter using twitter4j to retrieve all tweets from ScaDS (BigData Center). * It returns a list of statuses. * @return list of statuses * @throws TwitterException */ public static List<Status> getTweetsFromUser(String user) throws TwitterException { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); // Loads authentication data for twitter access from ./resources/application.conf (not in the Git repo) PropertiesLoaderJ propertiesLoader = new PropertiesLoaderJ(); configurationBuilder.setOAuthConsumerKey(propertiesLoader.oAuthConsumerKey) .setOAuthConsumerSecret(propertiesLoader.oAuthConsumerSecret) .setOAuthAccessToken(propertiesLoader.oAuthAccessToken) .setOAuthAccessTokenSecret(propertiesLoader.oAuthAccessTokenSecret); Twitter twitter = new TwitterFactory(configurationBuilder.build()).getInstance(); Paging paging = new Paging(1, 300); List<Status> statusList = twitter.getUserTimeline(user, paging); return statusList; }
Example #12
Source File: Twitter4jActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.day22_activity_twitter4j); mTweet = (EditText) findViewById(R.id.text_tweet); mButtonTweet = (Button) findViewById(R.id.button_tweet); mListView = (ListView) findViewById(R.id.list_view); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(API_KEY) .setOAuthConsumerSecret(API_SECRET) .setOAuthAccessToken(ACCESS_TOKEN) .setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET); mFactory = new TwitterFactory(cb.build()); new AsyncTimeline().execute(); mButtonTweet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTweet().execute(); } }); }
Example #13
Source File: TwitterSources.java From hazelcast-jet-contrib with Apache License 2.0 | 6 votes |
private TwitterBatchSourceContext( @Nonnull Properties credentials, @Nonnull String query ) throws TwitterException { checkTwitterCredentials(credentials); String consumerKey = credentials.getProperty("consumerKey"); String consumerSecret = credentials.getProperty("consumerSecret"); String token = credentials.getProperty("token"); String tokenSecret = credentials.getProperty("tokenSecret"); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(consumerKey) .setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(token) .setOAuthAccessTokenSecret(tokenSecret); this.twitter4JClient = new TwitterFactory(cb.build()) .getInstance(); this.searchResult = twitter4JClient.search(new Query(query)); }
Example #14
Source File: TwitterSentimentJobManager.java From Babler with Apache License 2.0 | 6 votes |
public TwitterSentimentJobManager() { languageDetector = new LanguageDetector(); for(int i =0; i< twitKey.length; i++) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(twitKey[i].getConsumer()) .setOAuthConsumerSecret(twitKey[i].getSecret()) .setOAuthAccessToken(twitKey[i].getAccess()) .setOAuthAccessTokenSecret(twitKey[i].getToken_secret()); TwitterFactory tf = new TwitterFactory(cb.build()); keys[i] = tf.getInstance(); } }
Example #15
Source File: TwitterJobManager.java From Babler with Apache License 2.0 | 6 votes |
public TwitterJobManager() { languageDetector = new LanguageDetector(); for(int i =0; i< twitKey.length; i++) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(twitKey[i].getConsumer()) .setOAuthConsumerSecret(twitKey[i].getSecret()) .setOAuthAccessToken(twitKey[i].getAccess()) .setOAuthAccessTokenSecret(twitKey[i].getToken_secret()); TwitterFactory tf = new TwitterFactory(cb.build()); keys[i] = tf.getInstance(); } }
Example #16
Source File: TwitterCodeSwitchSJobManager.java From Babler with Apache License 2.0 | 6 votes |
public TwitterCodeSwitchSJobManager() { languageDetector = new LanguageDetector(); for(int i =0; i< twitKey.length; i++) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(twitKey[i].getConsumer()) .setOAuthConsumerSecret(twitKey[i].getSecret()) .setOAuthAccessToken(twitKey[i].getAccess()) .setOAuthAccessTokenSecret(twitKey[i].getToken_secret()); TwitterFactory tf = new TwitterFactory(cb.build()); keys[i] = tf.getInstance(); } }
Example #17
Source File: TwitterJobManagerUser.java From Babler with Apache License 2.0 | 6 votes |
public TwitterJobManagerUser() { languageDetector = new LanguageDetector(); for(int i =0; i< twitKey.length; i++) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(twitKey[i].getConsumer()) .setOAuthConsumerSecret(twitKey[i].getSecret()) .setOAuthAccessToken(twitKey[i].getAccess()) .setOAuthAccessTokenSecret(twitKey[i].getToken_secret()); TwitterFactory tf = new TwitterFactory(cb.build()); keys[i] = tf.getInstance(); } }
Example #18
Source File: TwitterNotifier.java From yfiton with Apache License 2.0 | 6 votes |
public TwitterNotifier() throws NotificationException { super(CLIENT_ID, SECRET_ID, PromptReceiver.class, "com.yfiton.notifiers.twitter.TwitterWebEngineListener"); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder .setGZIPEnabled(true) .setDebugEnabled(true) .setOAuthConsumerKey(getClientId()) .setOAuthConsumerSecret(getClientSecret()); com.yfiton.notifiers.twitter.AccessToken accessToken = getAccessToken(); if (accessToken != null) { configurationBuilder.setOAuthAccessToken(accessToken.getAccessToken()); configurationBuilder.setOAuthAccessTokenSecret(accessToken.getAccessTokenSecret()); } twitter = new TwitterFactory( configurationBuilder.build()).getInstance(); }
Example #19
Source File: Twitter.java From BotLibre with Eclipse Public License 1.0 | 6 votes |
public void connect() throws TwitterException { initProperties(); ConfigurationBuilder config = new ConfigurationBuilder(); config.setOAuthConsumerKey(getOauthKey()); config.setOAuthConsumerSecret(getOauthSecret()); config.setOAuthAccessToken(getToken()); config.setOAuthAccessTokenSecret(getTokenSecret()); twitter4j.Twitter twitter = new TwitterFactory(config.build()).getInstance(); User user = twitter.verifyCredentials(); if (!this.userName.equals(user.getScreenName())) { this.userName = user.getScreenName(); saveProperties(null); } //AccessToken accessToken = new AccessToken(getToken(), getTokenSecret()); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(accessToken); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(getOauthKey(), getOauthSecret(), accessToken); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(getUsername(), getPassword()); setConnection(twitter); }
Example #20
Source File: TwitterSampleInput.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
private void setUpTwitterConnection() { ConfigurationBuilder cb = setupConfigurationBuilder(); ts = new TwitterStreamFactory(cb.build()).getInstance(); ts.addListener(TwitterSampleInput.this); // we can only listen to tweets containing links by callng ts.links(). // it seems it requires prior signed agreement with twitter. ts.sample(); }
Example #21
Source File: SoomlaTwitter.java From android-profile with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void configure(Map<String, String> providerParams) { autoLogin = false; if (providerParams != null) { twitterConsumerKey = providerParams.get("consumerKey"); twitterConsumerSecret = providerParams.get("consumerSecret"); // extract autoLogin String autoLoginStr = providerParams.get("autoLogin"); autoLogin = autoLoginStr != null && Boolean.parseBoolean(autoLoginStr); } SoomlaUtils.LogDebug(TAG, String.format( "ConsumerKey:%s ConsumerSecret:%s", twitterConsumerKey, twitterConsumerSecret)); if (TextUtils.isEmpty(twitterConsumerKey) || TextUtils.isEmpty(twitterConsumerSecret)) { SoomlaUtils.LogError(TAG, "You must provide the Consumer Key and Secret in the SoomlaProfile initialization parameters"); isInitialized = false; } else { isInitialized = true; } oauthCallbackURL = "oauth://soomla_twitter" + twitterConsumerKey; ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(twitterConsumerKey); configurationBuilder.setOAuthConsumerSecret(twitterConsumerSecret); Configuration configuration = configurationBuilder.build(); twitter = new AsyncTwitterFactory(configuration).getInstance(); if (!actionsListenerAdded) { SoomlaUtils.LogWarning(TAG, "added action listener"); twitter.addListener(actionsListener); actionsListenerAdded = true; } }
Example #22
Source File: Twitter4JHelper.java From personality-insights-twitter-java with Apache License 2.0 | 5 votes |
/** * Instantiates a new twitter 4 J helper. * * @param properties the properties * @throws Exception the exception */ public Twitter4JHelper(Properties properties) throws Exception { String consumerKey = properties.getProperty(CONSUMER_KEY); String consumerSecret = properties.getProperty(CONSUMER_SECRET); String accessToken = properties.getProperty(ACCESS_TOKEN); String accessSecret = properties.getProperty(ACCESS_SECRET); // Validate that these are set and throw an error if they are not if (consumerKey == null || consumerKey.isEmpty()) { throw new Exception(CONSUMER_KEY + " cannot be null"); } if (consumerSecret == null || consumerSecret.isEmpty()) { throw new Exception(CONSUMER_SECRET + " cannot be null"); } if (accessToken == null || accessToken.isEmpty()) { throw new Exception(ACCESS_TOKEN + " cannot be null"); } if (accessSecret == null || accessSecret.isEmpty()) { throw new Exception(ACCESS_SECRET + " cannot be null"); } ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(consumerKey) .setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken) .setOAuthAccessTokenSecret(accessSecret); TwitterFactory twitterFactory = new TwitterFactory(cb.build()); client = twitterFactory.getInstance(); client.addRateLimitStatusListener(this); }
Example #23
Source File: TwitterReader.java From swcv with MIT License | 5 votes |
public static Twitter getTwitterInstance() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(false); cb.setOAuthConsumerKey(TwitterCredentials.CONSUMER_KEY); cb.setOAuthConsumerSecret(TwitterCredentials.CONSUMER_SECRET); cb.setOAuthAccessToken(TwitterCredentials.ACCESS_TOKEN); cb.setOAuthAccessTokenSecret(TwitterCredentials.ACCESS_TOKEN_SECRET); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
Example #24
Source File: TwitterApi.java From SmileEssence with MIT License | 5 votes |
public static Configuration getConf(String consumerKey, String consumerSecret) { ConfigurationBuilder conf = new ConfigurationBuilder(); conf.setOAuthConsumerKey(consumerKey); conf.setOAuthConsumerSecret(consumerSecret); conf.setDebugEnabled(true); return conf.build(); }
Example #25
Source File: Twitt4droid.java From twitt4droid with Apache License 2.0 | 5 votes |
/** * Gets the current twitter4j configuration with consumer and access tokens pre-initialized. You * can use this method to build a Twitter objects. * * @param context the application context. * @return an Configuration object. */ private static Configuration getCurrentConfig(Context context) { SharedPreferences preferences = Resources.getPreferences(context); return new ConfigurationBuilder() .setOAuthConsumerKey(Resources.getMetaData(context, context.getString(R.string.twitt4droid_consumer_key_metadata), null)) .setOAuthConsumerSecret(Resources.getMetaData(context, context.getString(R.string.twitt4droid_consumer_secret_metadata), null)) .setOAuthAccessToken(preferences.getString(context.getString(R.string.twitt4droid_oauth_token_key), null)) .setOAuthAccessTokenSecret(preferences.getString(context.getString(R.string.twitt4droid_oauth_secret_key), null)) .build(); }
Example #26
Source File: Twitter4jSampleActivity.java From android-opensource-library-56 with Apache License 2.0 | 5 votes |
private void startOAuth() { new Thread() { public void run() { ConfigurationBuilder cbuilder = new ConfigurationBuilder(); cbuilder.setOAuthConsumerKey(Settings.CONSUMER_KEY); cbuilder.setOAuthConsumerSecret(Settings.CONSUMER_SECRET); Configuration conf = cbuilder.build(); mOauth = new OAuthAuthorization(conf); String authUrl = null; try { RequestToken requestToken = mOauth .getOAuthRequestToken(null); authUrl = requestToken.getAuthorizationURL(); } catch (Exception e) { e.printStackTrace(); return; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }; }.start(); setContentView(R.layout.login); findViewById(R.id.login).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ピンコード処理を書く EditText editText = (EditText) findViewById(R.id.pincode); getOAuthAccessToken(editText.getText().toString()); } }); }
Example #27
Source File: TwitterInstance.java From android-opensource-library-56 with Apache License 2.0 | 5 votes |
public static Twitter getTwitterInstance(Context context) { if (INSTANCE == null) { Settings settings = Settings.getInstance(context); ConfigurationBuilder cbuilder = new ConfigurationBuilder(); cbuilder.setOAuthConsumerKey(Settings.CONSUMER_KEY); cbuilder.setOAuthConsumerSecret(Settings.CONSUMER_SECRET); cbuilder.setOAuthAccessToken(settings.getAccessToken()); cbuilder.setOAuthAccessTokenSecret(settings.getAccessTokenSecret()); Configuration c = cbuilder.build(); TwitterFactory twitterFactory = new TwitterFactory(c); INSTANCE = twitterFactory.getInstance(); } return INSTANCE; }
Example #28
Source File: TwitterStreamTracker.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
private static Configuration task2configuration(CollectionTask task) { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setDebugEnabled(false) .setJSONStoreEnabled(true) .setOAuthConsumerKey(configProperties.getProperty(CollectorConfigurationProperty.TWITTER_CONSUMER_KEY)) .setOAuthConsumerSecret(configProperties.getProperty(CollectorConfigurationProperty.TWITTER_CONSUMER_SECRET)) .setOAuthAccessToken(task.getAccessToken()) .setOAuthAccessTokenSecret(task.getAccessTokenSecret()); Configuration configuration = configurationBuilder.build(); return configuration; }
Example #29
Source File: TwitterShowUserServlet.java From keycloak with Apache License 2.0 | 5 votes |
@Override protected void doGet(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { TwitterOAuthResponse twitterOAuthResponse = getTwitterOAuthResponse(request); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(this.identityProvider.getConfig().get("clientId")) .setOAuthConsumerSecret(this.identityProvider.getConfig().get("clientSecret")) .setOAuthAccessToken(twitterOAuthResponse.getToken()) .setOAuthAccessTokenSecret(twitterOAuthResponse.getTokenSecret()); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); try { User user = twitter.users().showUser(twitterOAuthResponse.getScreenName()); response.setContentType(MediaType.APPLICATION_JSON); PrintWriter writer = response.getWriter(); writer.println(new ObjectMapper().writeValueAsString(user)); writer.flush(); } catch (TwitterException e) { throw new RuntimeException("Could not load social profile.", e); } }
Example #30
Source File: TwitterOauthWizard.java From Onosendai with Apache License 2.0 | 5 votes |
private Configuration getTwitterConfiguration () { if (this.twitterConfiguration == null) { final ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(TwitterOauth.getConsumerKey()); builder.setOAuthConsumerSecret(TwitterOauth.getConsumerSecret()); this.twitterConfiguration = builder.build(); } return this.twitterConfiguration; }