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


Java ConfigurationBuilder.setOAuthConsumerKey方法代碼示例

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


在下文中一共展示了ConfigurationBuilder.setOAuthConsumerKey方法的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: 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:SamKnows,項目名稱:skandroid-core,代碼行數:22,代碼來源:ApplicationOnlyAuthTest.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: 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

示例11: doInBackground

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
protected Void doInBackground(Void... voids) {

	ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
	configurationBuilder
			.setOAuthConsumerKey(getString(R.string.TWITTER_CONSUMER_KEY));
	configurationBuilder
			.setOAuthConsumerSecret(getString(R.string.TWITTER_CONSUMER_SECRET));
	Configuration configuration = configurationBuilder.build();
	twitter = new TwitterFactory(configuration).getInstance();

	try {
		RequestToken requestToken = twitter
				.getOAuthRequestToken(getString(R.string.TWITTER_CALLBACK_URL));
		launchLoginWebView(requestToken);
	} catch (TwitterException e) {
		e.printStackTrace();

	}
	return null;
}
 
開發者ID:Pi-Developers,項目名稱:Floata-Client,代碼行數:22,代碼來源:MainActivity.java

示例12: loginTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void loginTwitter(){
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
    builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
    Configuration configuration = builder.build();

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

    try {
        requestToken = twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);

        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
    } catch (TwitterException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Night-Developer,項目名稱:Twitter-j4,代碼行數:18,代碼來源:MyActivity.java

示例13: loginToTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private void loginToTwitter() {
	// Check if already logged in

	ConfigurationBuilder builder = new ConfigurationBuilder();
	builder.setOAuthConsumerKey(Config.TWITTER_CONSUMER_KEY);
	builder.setOAuthConsumerSecret(Config.TWITTER_CONSUMER_SECRET);
	Configuration configuration = builder.build();

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

	try {
		requestToken = twitter.getOAuthRequestToken(Config.TWITTER_CALLBACK_URL);
		this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
	} catch (TwitterException e) {
		e.printStackTrace();
	}
}
 
開發者ID:JCERTIFLab,項目名稱:jcertif-android-2013,代碼行數:19,代碼來源:LoginFragment.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: init

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@PostConstruct
public void init() {
  try {
    File log = new File(logFile);
    File parentDir = log.getParentFile();
    if (!parentDir.exists()) {
      parentDir.mkdirs();
    }

    FileHandler fh = new FileHandler(logFile);
    logger.addHandler(fh);
    SimpleFormatter formatter = new SimpleFormatter();
    fh.setFormatter(formatter);

    File fbLog = new File(fallbackLogFile);
    File fbParentDir = fbLog.getParentFile();
    if (!fbParentDir.exists()) {
      fbParentDir.mkdirs();
    }

    FileHandler fbFh = new FileHandler(fallbackLogFile);
    fbLogger.addHandler(fbFh);
    SimpleFormatter fbFormatter = new SimpleFormatter();
    fbFh.setFormatter(fbFormatter);

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);
    cb.setTweetModeExtended(true);
    cb.setOAuthConsumerKey(consumerKey);
    cb.setOAuthConsumerSecret(consumeSecret);
    cb.setOAuthAccessToken(accessToken);
    cb.setOAuthAccessTokenSecret(acessSecret);
    TwitterFactory tf = new TwitterFactory(cb.build());
    twitter = tf.getInstance();
  } catch (Exception e) {
    throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
  }
}
 
開發者ID:OpenLiberty,項目名稱:sample-acmegifts,代碼行數:39,代碼來源:NotificationResource.java


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