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