本文整理匯總了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);
}
示例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);
}
示例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) {
}
}
示例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);
}
示例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();
}
}
示例6: setUp
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
super.setUp();
builder = new ConfigurationBuilder();
builder.setUseSSL(true);
builder.setApplicationOnlyAuthEnabled(true);
}
示例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();
}
示例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;
}