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


Java ConfigurationBuilder.setUseSSL方法代碼示例

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


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

示例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.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

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

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

示例5: askOAuth

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private void askOAuth() {
	ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
	configurationBuilder.setOAuthConsumerKey(Const.TWITTER_CONSUMER_KEY);
	configurationBuilder.setOAuthConsumerSecret(Const.TWITTER_CONSUMER_SECRET);
	configurationBuilder.setUseSSL(true);
	Configuration configuration = configurationBuilder.build();
	twitter = new TwitterFactory(configuration).getInstance();
	try {
		requestToken = twitter.getOAuthRequestToken(Const.CALLBACK_URL);
		Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show();
		this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
	} catch (TwitterException e) {
		e.printStackTrace();
	}
}
 
開發者ID:guiruiz,項目名稱:Twiteckon,代碼行數:16,代碼來源:TwitterApp.java

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

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

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


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