當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurationBuilder.setOAuthConsumerSecret方法代碼示例

本文整理匯總了Java中twitter4j.conf.ConfigurationBuilder.setOAuthConsumerSecret方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationBuilder.setOAuthConsumerSecret方法的具體用法?Java ConfigurationBuilder.setOAuthConsumerSecret怎麽用?Java ConfigurationBuilder.setOAuthConsumerSecret使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twitter4j.conf.ConfigurationBuilder的用法示例。


在下文中一共展示了ConfigurationBuilder.setOAuthConsumerSecret方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private Twitter getTwitter() {
    TwitterCredentials creds = readCredentials();
    if (creds.getConsumerKey() == null) {
        throw new RuntimeException("Incorrect Twitter client configuration: Consumer key is null");
    }
    if (creds.getConsumerSecret() == null) {
        throw new RuntimeException("Incorrect Twitter client configuration: Consumer secret is null");
    }
    if (creds.getAccessSecret() == null) {
        throw new RuntimeException("Incorrect Twitter client configuration: Access secret is null");
    }
    if (creds.getAccessToken() == null) {
        throw new RuntimeException("Incorrect Twitter client configuration: Access token is null");
    }
    ConfigurationBuilder twitterConfig = new ConfigurationBuilder();
    twitterConfig.setOAuthConsumerKey(creds.getConsumerKey());
    twitterConfig.setOAuthConsumerSecret(creds.getConsumerSecret());
    twitterConfig.setOAuthAccessToken(creds.getAccessToken());
    twitterConfig.setOAuthAccessTokenSecret(creds.getAccessSecret());
    twitterConfig.setJSONStoreEnabled(true);
    return new TwitterFactory(twitterConfig.build()).getInstance();
}
 
開發者ID:arun-gupta,項目名稱:tweet-analysis,代碼行數:23,代碼來源:TwitterFeed.java

示例2: configureTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private static Twitter configureTwitter(Account account) {
    final ConfigurationBuilder builder = new ConfigurationBuilder();

    builder.setOAuthConsumerKey(Config.TWITTER_CONSUMER_KEY);
    builder.setOAuthConsumerSecret(Config.TWITTER_CONSUMER_SECRET);
    builder.setOAuthAccessTokenSecret(account.tokenSecret());
    builder.setOAuthAccessToken(account.token());

    return new TwitterFactory(builder.build()).getInstance();
}
 
開發者ID:mecid,項目名稱:robird-reborn,代碼行數:11,代碼來源:BaseTwitterModel.java

示例3: twitterStream

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Bean
public TwitterStream twitterStream() {
	String consumerKey = environment.getRequiredProperty("consumerKey");
	String consumerSecret = environment.getRequiredProperty("consumerSecret");
	String accessToken = environment.getRequiredProperty("accessToken");
	String accessTokenSecret = environment.getRequiredProperty("accessTokenSecret");

	ConfigurationBuilder cb = new ConfigurationBuilder();
	cb.setOAuthConsumerKey(consumerKey);
	cb.setOAuthConsumerSecret(consumerSecret);
	cb.setOAuthAccessToken(accessToken);
	cb.setOAuthAccessTokenSecret(accessTokenSecret);
	cb.setJSONStoreEnabled(true);
	cb.setIncludeEntitiesEnabled(true);

	return new TwitterStreamFactory(cb.build()).getInstance();
}
 
開發者ID:malejpavouk,項目名稱:kafka-twitter-producer,代碼行數:18,代碼來源:TwitterProducerApp.java

示例4: testSettingAccessToken2

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void testSettingAccessToken2() throws TwitterException {
    // setup
    builder.setOAuthConsumerKey(browserConsumerKey).setOAuthConsumerSecret(browserConsumerSecret);
    OAuth2Token token = new TwitterFactory(builder.build()).getInstance().getOAuth2Token();

    // exercise & verify
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setApplicationOnlyAuthEnabled(true);
    cb.setOAuthConsumerKey(browserConsumerKey);
    cb.setOAuthConsumerSecret(browserConsumerSecret);
    cb.setOAuth2TokenType(token.getTokenType());
    cb.setOAuth2AccessToken(token.getAccessToken());

    Twitter twitter = new TwitterFactory(cb.build()).getInstance();

    Map<String, RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus("search");
    RateLimitStatus searchTweetsRateLimit = rateLimitStatus.get("/search/tweets");
    assertNotNull(searchTweetsRateLimit);
    assertEquals(searchTweetsRateLimit.getLimit(), 450);
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:21,代碼來源:ApplicationOnlyAuthTest.java

示例5: getConfiguration

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
 * Builds a Twitter4J Configuration using the OAuth params.
 *
 * @return Configuration
 */
public Configuration getConfiguration() {
    checkComplete();
    ConfigurationBuilder confBuilder = new ConfigurationBuilder();
    confBuilder.setOAuthConsumerKey(consumerKey);
    confBuilder.setOAuthConsumerSecret(consumerSecret);
    confBuilder.setOAuthAccessToken(accessToken);
    confBuilder.setOAuthAccessTokenSecret(accessTokenSecret);
    if (getHttpProxyHost() != null) {
        confBuilder.setHttpProxyHost(getHttpProxyHost());
    }
    if (getHttpProxyUser() != null) {
        confBuilder.setHttpProxyHost(getHttpProxyUser());
    }
    if (getHttpProxyPassword() != null) {
        confBuilder.setHttpProxyHost(getHttpProxyPassword());
    }
    if (httpProxyPort != null) {
        confBuilder.setHttpProxyPort(httpProxyPort);
    }
    
    return confBuilder.build();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:TwitterConfiguration.java

示例6: main

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
	
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);
    cb.setOAuthConsumerKey("P9sUs46f03m4xAJZzxt7Q");
    cb.setOAuthConsumerSecret("Czw2g7QoURXz5WoLE8AbMounBiVAONktlQP1YleEy0");
    cb.setOAuthAccessToken("182798423-gFyyrktqZmcrTu916G7zTkNX3pnTsB8Zc4s22dOc");
    cb.setOAuthAccessTokenSecret("ITKJnDENspq5dVZIQMjTtG4NOj2ioT0QE2DkE9ZZA");

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

    CStreamListener objStreamListener = new CStreamListener();

    FilterQuery fq = new FilterQuery();

    String [] keywords = TwitterConst.KEYWORDS;

    fq.track(keywords);

    twitterStream.addListener(objStreamListener);
    twitterStream.filter(fq);
}
 
開發者ID:almightyGOSU,項目名稱:CZ4045-NLP-Crawler,代碼行數:26,代碼來源:Twitter4JTesting.java

示例7: connect

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
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);
}
 
開發者ID:BotLibre,項目名稱:BotLibre,代碼行數:20,代碼來源:Twitter.java

示例8: configure

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
public void configure(Properties props) {
	ProducerConfig config = new ProducerConfig(props);
	producer = new Producer<String, String>(config);
	
	// The necessary authentication keys to connect to twitter API v1.1
    String consumerKey = props.getProperty(TwitterProducerConstants.CONSUMER_KEY_KEY);
    String consumerSecret = props.getProperty(TwitterProducerConstants.CONSUMER_SECRET_KEY);
    String accessToken = props.getProperty(TwitterProducerConstants.ACCESS_TOKEN_KEY);
    String accessTokenSecret = props.getProperty(TwitterProducerConstants.ACCESS_TOKEN_SECRET_KEY);
	
	ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setOAuthConsumerKey(consumerKey);
    cb.setOAuthConsumerSecret(consumerSecret);
    cb.setOAuthAccessToken(accessToken);
    cb.setOAuthAccessTokenSecret(accessTokenSecret);
    cb.setJSONStoreEnabled(true);
    cb.setIncludeEntitiesEnabled(true);

    twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
}
 
開發者ID:Sentaware,項目名稱:kafka-producers,代碼行數:22,代碼來源:TwitterProducer.java

示例9: TimelineStream

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
 * <p>
 * Creates a new {@code TimelineStream} instance with the given OAuth
 * information to use for collection.
 * </p>
 * 
 * @param consumerKey
 *            the Twitter consumer key to use
 * @param consumerSecret
 *            the Twitter consumer secret to use
 * @param accessToken
 *            the Twitter access token to use
 * @param accessTokenSecret
 *            the Twitter access token secret to use
 */
public TimelineStream(String consumerKey, String consumerSecret,
		String accessToken, String accessTokenSecret) {
	this.setShouldShutdown(false);
	this.setShutdownWhenEmpty(false);

	this.userIds = new LinkedBlockingQueue<Long>();
	this.listeners = new HashSet<TimelineStreamListener>();

	// get oauth -> build twitter collection object
	ConfigurationBuilder cb = new ConfigurationBuilder();
	cb.setOAuthConsumerKey(consumerKey);
	cb.setOAuthConsumerSecret(consumerSecret);
	cb.setOAuthAccessToken(accessToken);
	cb.setOAuthAccessTokenSecret(accessTokenSecret);

	// (timeout from original TLC code)
	cb.setHttpConnectionTimeout(40000);
	this.twitter = new TwitterFactory(cb.build()).getInstance();
}
 
開發者ID:rmachedo,項目名稱:MEater,代碼行數:35,代碼來源:TimelineStream.java

示例10: loginToTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
 * Function to login twitter
 * */
private void loginToTwitter() {
    // Check if already logged in
    if (!isTwitterLoggedInAlready()) {
        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
        builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
        Configuration configuration = builder.build();
         
        TwitterFactory factory = new TwitterFactory(configuration);
        twitter = factory.getInstance();
 
        try {
            requestToken = twitter
                    .getOAuthRequestToken(TWITTER_CALLBACK_URL);
            this.startActivity(new Intent(Intent.ACTION_VIEW, Uri
                    .parse(requestToken.getAuthenticationURL())));
        } catch (TwitterException e) {
            e.printStackTrace();
        }
    } else {
        // user already logged into twitter
        Toast.makeText(getApplicationContext(),
                "Already Logged into twitter", Toast.LENGTH_LONG).show();
    }
}
 
開發者ID:captainstu72,項目名稱:tycka,代碼行數:29,代碼來源:TickerActivity.java

示例11: verifyTwitterCredentials

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
protected boolean verifyTwitterCredentials()
{
    Twitter twitter;
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setOAuthConsumerKey(mOAuthData.getConsumerKey());
    cb.setOAuthConsumerSecret(mOAuthData.getConsumerSecret());
    cb.setOAuthAccessToken(mOAuthData.getAccessToken());
    cb.setOAuthAccessTokenSecret(mOAuthData.getAccessTokenSecret());


    TwitterFactory tf = new TwitterFactory(cb.build());
    twitter = tf.getInstance();

    try {
        User user = twitter.verifyCredentials();
        return true;

    } catch (TwitterException te) {
        return false;
    }
}
 
開發者ID:ThisPlace,項目名稱:MindRDR,代碼行數:22,代碼來源:OAuthActivity.java

示例12: init

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
 * Initializes this gateway
 */
@Override
@SuppressWarnings("rawtypes")
public void init(final GatewayEngine engine, final String id, final String cfcPath, final Map config) throws IOException
{
  try
  {
    this.argType = ArgumentType.fromConfigValue((String) config.get(ARGUMENT_TYPE));
    final ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setOAuthConsumerKey((String) config.get(OAUTH_CONSUMER_KEY));
    cb.setOAuthConsumerSecret((String) config.get(OAUTH_CONSUMER_SECRET));
    cb.setOAuthAccessToken((String) config.get(OAUTH_ACCESS_TOKEN));
    cb.setOAuthAccessTokenSecret((String) config.get(OAUTH_ACCESS_SECRET));
    cb.setUserStreamRepliesAllEnabled(Boolean.valueOf((String) config.get(ALL_REPLIES)));
    cb.setJSONStoreEnabled(ArgumentType.JSON.equals(this.argType));
    super.init(engine, id, new TwitterUserStream(this, cb.build()));
  }
  catch (Throwable t)
  {
    final IOException ex = new IOException("Unable to initialize gateway", t);
    this.onException(ex);
    throw ex;
  }
}
 
開發者ID:jbvanzuylen,項目名稱:cf-twitter-gateway,代碼行數:27,代碼來源:RailoTwitterUserStreamGateway.java

示例13: testSettingAccessToken2

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void testSettingAccessToken2() throws TwitterException {
    // setup
    builder.setOAuthConsumerKey(browserConsumerKey).setOAuthConsumerSecret(browserConsumerSecret);
    OAuth2Token token = new TwitterFactory(builder.build()).getInstance().getOAuth2Token();

    // exercise & verify
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setUseSSL(true);
    cb.setApplicationOnlyAuthEnabled(true);
    cb.setOAuthConsumerKey(browserConsumerKey);
    cb.setOAuthConsumerSecret(browserConsumerSecret);
    cb.setOAuth2TokenType(token.getTokenType());
    cb.setOAuth2AccessToken(token.getAccessToken());

    Twitter twitter = new TwitterFactory(cb.build()).getInstance();

    Map<String, RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus("search");
    RateLimitStatus searchTweetsRateLimit = rateLimitStatus.get("/search/tweets");
    assertNotNull(searchTweetsRateLimit);
    assertEquals(searchTweetsRateLimit.getLimit(), 450);
}
 
開發者ID:vaglucas,項目名稱:cafeUnoesc,代碼行數:22,代碼來源:ApplicationOnlyAuthTest.java

示例14: loginToTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private void loginToTwitter() {
	// Check if already logged in
	if (!isTwitterLoggedInAlready()) {
		ConfigurationBuilder builder = new ConfigurationBuilder();
		builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
		builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
		Configuration configuration = builder.build();

		TwitterFactory factory = new TwitterFactory(configuration);
		twitter = factory.getInstance();

		try {
			requestToken = twitter
					.getOAuthRequestToken(TWITTER_CALLBACK_URL);
			this.startActivity(new Intent(Intent.ACTION_VIEW, Uri
					.parse(requestToken.getAuthenticationURL())));
		} catch (TwitterException e) {
			e.printStackTrace();
		}
	} else {
		// user already logged into twitter
		Toast.makeText(getApplicationContext(),
				"Already Logged into twitter", Toast.LENGTH_LONG).show();
	}
}
 
開發者ID:benoffi7,項目名稱:cursoAndroidUTN,代碼行數:26,代碼來源:lay_twitter.java

示例15: getTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private static Twitter getTwitter(HandlerContext handlerContext) {
    Twitter res = (Twitter) handlerContext.get("twitter");
    if (res == null) {
        TwitterFollowHandlerConfig twitterFollowHandlerConfig = (TwitterFollowHandlerConfig) handlerContext.getHandlerConfig();
        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
        configurationBuilder.setDebugEnabled(true).setOAuthConsumerKey(twitterFollowHandlerConfig.getOauthConsumerKey());
        configurationBuilder.setOAuthConsumerSecret(twitterFollowHandlerConfig.getOauthConsumerSecret());
        configurationBuilder.setOAuthAccessToken(twitterFollowHandlerConfig.getOauthAccessToken());
        configurationBuilder.setOAuthAccessTokenSecret(twitterFollowHandlerConfig.getOauthAccessTokenSecret());
        TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build());
        res = twitterFactory.getInstance();

        handlerContext.put("twitter", res);
    }
    return res;
}
 
開發者ID:BoD,項目名稱:irondad,代碼行數:17,代碼來源:TwitterFollowHandler.java


注:本文中的twitter4j.conf.ConfigurationBuilder.setOAuthConsumerSecret方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。