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


Java ConfigurationBuilder.setApplicationOnlyAuthEnabled方法代碼示例

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


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

示例1: testSettingAccessToken1

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void testSettingAccessToken1() 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);

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

    twitter.setOAuthConsumer(browserConsumerKey, browserConsumerSecret);
    twitter.setOAuth2Token(token);

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

示例2: 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

示例3: testOAuth2Instance

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void testOAuth2Instance() throws Exception {
    String consumerSecret = p.getProperty("browser.oauth.consumerSecret");
    String consumerKey = p.getProperty("browser.oauth.consumerSecret");

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setApplicationOnlyAuthEnabled(true);

    Twitter twitter = new TwitterFactory(cb.build()).getInstance();
    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    try {
        twitter.setOAuthConsumer(consumerSecret, consumerKey);
        fail("should throw IllegalStateException");
    } catch (IllegalStateException ignore) {
    }

    Authorization auth = twitter.getAuthorization();
    assertTrue(auth instanceof OAuth2Authorization);
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:19,代碼來源:AuthorizationTest.java

示例4: getTwitterInstance

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public static Twitter getTwitterInstance() throws TwitterException {
	if (twitter == null) {
		final ConfigurationBuilder cb = new ConfigurationBuilder();
		cb.setDebugEnabled(true);
		cb.setApplicationOnlyAuthEnabled(true);

		final OAuth2Token token = getOAuth2Token();
		cb.setOAuth2TokenType(token.getTokenType());
		cb.setOAuth2AccessToken(token.getAccessToken());

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

	return twitter;
}
 
開發者ID:ganeshjawahar,項目名稱:ire-seimp,代碼行數:17,代碼來源:TwitterManager.java

示例5: testSettingAccessToken1

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void testSettingAccessToken1() 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);

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

    twitter.setOAuthConsumer(browserConsumerKey, browserConsumerSecret);
    twitter.setOAuth2Token(token);

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

示例6: 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

示例7: testRequiringSSL

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void testRequiringSSL() {
    // setup
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setUseSSL(false);
    cb.setOAuth2TokenURL("http://api.twitter.com/oauth2/token");
    cb.setApplicationOnlyAuthEnabled(true);

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

    // exercise & verify
    twitter.setOAuthConsumer(browserConsumerKey, browserConsumerSecret);
    try {
        twitter.getOAuth2Token();
        fail("should throw TwitterException");

    } catch (TwitterException ignore) {
    }
}
 
開發者ID:SamKnows,項目名稱:skandroid-core,代碼行數:19,代碼來源:ApplicationOnlyAuthTest.java

示例8: testOAuth2Instance

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void testOAuth2Instance() throws Exception {
    String consumerSecret = p.getProperty("browser.oauth.consumerSecret");
    String consumerKey = p.getProperty("browser.oauth.consumerSecret");

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setApplicationOnlyAuthEnabled(true);
    cb.setUseSSL(true);

    Twitter twitter = new TwitterFactory(cb.build()).getInstance();
    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    try {
        twitter.setOAuthConsumer(consumerSecret, consumerKey);
        fail("should throw IllegalStateException");
    } catch (IllegalStateException ignore) {
    }

    Authorization auth = twitter.getAuthorization();
    assertTrue(auth instanceof OAuth2Authorization);
}
 
開發者ID:SamKnows,項目名稱:skandroid-core,代碼行數:20,代碼來源:AuthorizationTest.java

示例9: getOAuth2Token

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private static OAuth2Token getOAuth2Token() throws TwitterException {
	OAuth2Token token = null;
	ConfigurationBuilder cb = new ConfigurationBuilder();
	cb.setApplicationOnlyAuthEnabled(true);
	token = new TwitterFactory(cb.build()).getInstance().getOAuth2Token();
	return token;
}
 
開發者ID:ganeshjawahar,項目名稱:ire-seimp,代碼行數:8,代碼來源:TwitterManager.java

示例10: setUp

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    builder = new ConfigurationBuilder();
    builder.setUseSSL(true);
    builder.setApplicationOnlyAuthEnabled(true);
}
 
開發者ID:SamKnows,項目名稱:skandroid-core,代碼行數:8,代碼來源:ApplicationOnlyAuthTest.java

示例11: buildConfiguration

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private Configuration buildConfiguration() {
    final ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setUseSSL(useSsl);
    builder.setJSONStoreEnabled(true);
    builder.setApplicationOnlyAuthEnabled(true);
    if (StringUtils.isNotBlank(httpProxyHost) && httpProxyPort > 0) {
        builder.setHttpProxyHost(httpProxyHost);
        builder.setHttpProxyPort(httpProxyPort);
    }
    return builder.build();
}
 
開發者ID:Adobe-Consulting-Services,項目名稱:acs-aem-commons,代碼行數:12,代碼來源:TwitterAdapterFactory.java

示例12: setUp

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    builder = new ConfigurationBuilder();
    builder.setApplicationOnlyAuthEnabled(true);
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:7,代碼來源:ApplicationOnlyAuthTest.java

示例13: getTweets

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public static ArrayList<Tweet> getTweets(String searchTerm, int count, Context context) {

        ArrayList<Tweet> tweets = new ArrayList<Tweet>();
        
        try {
        	
        	builder = new ConfigurationBuilder();
        	builder.setDebugEnabled(true);
            builder.setUseSSL(true);
            builder.setApplicationOnlyAuthEnabled(true);
        	builder.setOAuthConsumerKey("xxx").setOAuthConsumerSecret("xxx");
            OAuth2Token token = new TwitterFactory(builder.build()).getInstance().getOAuth2Token();
        	
        	// exercise & verify
            ConfigurationBuilder cb = new ConfigurationBuilder();
            cb.setDebugEnabled(true);
            cb.setUseSSL(true);
            cb.setApplicationOnlyAuthEnabled(true);
            cb.setOAuthConsumerKey("xxx");
            cb.setOAuthConsumerSecret("xxx");
            cb.setOAuth2TokenType(token.getTokenType());
            cb.setOAuth2AccessToken(token.getAccessToken());

            Twitter twitter = new TwitterFactory(cb.build()).getInstance();
            
            Query query = new Query(searchTerm);
            query.setCount(count);
            QueryResult result = twitter.search(query);
            for (Status status : result.getTweets()) {
                //Log.d(TAG, "Screen Name " + status.getUser().getScreenName());

                Tweet tweet = new Tweet(
                        status.getUser().getScreenName().toString(),                //from_user
                        status.getText().toString(),                                //"text"
                        status.getUser().getBiggerProfileImageURL().toString(),     //"profile_image_url"
                        status.getCreatedAt().toString());                          //"created_at"
                tweets.add(tweet);
            }
            
        }
        catch (TwitterException t)
        {
            //Log.d(TAG, "Twitter Error " + t.toString());
        }
        catch (Exception e)
        {
            //Log.d(TAG, "Error " + e.toString());
        }

		return tweets;
	}
 
開發者ID:JasonBrannon,項目名稱:GoVRE,代碼行數:52,代碼來源:ProxyNetworkTwitter.java

示例14: setUp

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
 * Inicializar
 */
public void setUp() {

    builder = new ConfigurationBuilder();
    // builder.setUseSSL(true);
    builder.setApplicationOnlyAuthEnabled(true);

    try {

        twitter = new TwitterFactory(builder.build()).getInstance();

        twitter.setOAuthConsumer(Constantes.ck, Constantes.cs);

        // Para que cargue
        OAuth2Token token = twitter.getOAuth2Token();

    } catch (TwitterException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
 
開發者ID:alberapps,項目名稱:tiempobus,代碼行數:25,代碼來源:ProcesarTwitter4j.java


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