本文整理匯總了Java中twitter4j.conf.ConfigurationBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationBuilder類的具體用法?Java ConfigurationBuilder怎麽用?Java ConfigurationBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConfigurationBuilder類屬於twitter4j.conf包,在下文中一共展示了ConfigurationBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setup twitter client
mTwitter = new TwitterFactory(new ConfigurationBuilder()
.setOAuthConsumerKey(getResources().getString(R.string.twitter_consumer_key))
.setOAuthConsumerSecret(getResources().getString(R.string.twitter_consumer_secret))
.build()).getInstance();
// setup twitter webview
mTwitterView = new WebView(this);
mTwitterView.getSettings().setJavaScriptEnabled(true);
// initialize view
setContentView(mTwitterView);
// start the web view
loginToTwitter();
}
示例2: twitterFactory
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean
public TwitterFactory twitterFactory() {
if (this.properties.getConsumerKey() == null
|| this.properties.getConsumerSecret() == null
|| this.properties.getAccessToken() == null
|| this.properties.getAccessTokenSecret() == null) {
throw new RuntimeException(
"Twitter properties not configured properly. Please check twitter.* properties settings in configuration file.");
}
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setDebugEnabled(false)
.setOAuthConsumerKey(properties.getConsumerKey())
.setOAuthConsumerSecret(properties.getConsumerSecret())
.setOAuthAccessToken(properties.getAccessToken())
.setOAuthAccessTokenSecret(properties.getAccessTokenSecret());
return new TwitterFactory(configurationBuilder.build());
}
示例3: 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();
}
示例4: TwSfValidationSteps
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public TwSfValidationSteps() {
accountsDirectory = AccountsDirectory.getInstance();
final Account twitterTalky = accountsDirectory.getAccount(RestConstants.getInstance().getSYNDESIS_TALKY_ACCOUNT()).get();
//twitter
final TwitterFactory factory = new TwitterFactory(new ConfigurationBuilder()
.setOAuthConsumerKey(twitterTalky.getProperty("consumerKey"))
.setOAuthConsumerSecret(twitterTalky.getProperty("consumerSecret"))
.setOAuthAccessToken(twitterTalky.getProperty("accessToken"))
.setOAuthAccessTokenSecret(twitterTalky.getProperty("accessTokenSecret"))
.build());
twitter = factory.getInstance();
// salesforce
final Account salesforceAccount = accountsDirectory.getAccount("salesforce").get();
salesforce = new ForceApi(new ApiConfig()
.setClientId(salesforceAccount.getProperty("clientId"))
.setClientSecret(salesforceAccount.getProperty("clientSecret"))
.setUsername(salesforceAccount.getProperty("userName"))
.setPassword(salesforceAccount.getProperty("password"))
.setForceURL(salesforceAccount.getProperty("loginUrl")));
}
示例5: TwitterJobManagerUser
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public TwitterJobManagerUser()
{
languageDetector = new LanguageDetector();
for(int i =0; i< twitKey.length; i++)
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(twitKey[i].getConsumer())
.setOAuthConsumerSecret(twitKey[i].getSecret())
.setOAuthAccessToken(twitKey[i].getAccess())
.setOAuthAccessTokenSecret(twitKey[i].getToken_secret());
TwitterFactory tf = new TwitterFactory(cb.build());
keys[i] = tf.getInstance();
}
}
示例6: TwitterCodeSwitchSJobManager
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public TwitterCodeSwitchSJobManager()
{
languageDetector = new LanguageDetector();
for(int i =0; i< twitKey.length; i++)
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(twitKey[i].getConsumer())
.setOAuthConsumerSecret(twitKey[i].getSecret())
.setOAuthAccessToken(twitKey[i].getAccess())
.setOAuthAccessTokenSecret(twitKey[i].getToken_secret());
TwitterFactory tf = new TwitterFactory(cb.build());
keys[i] = tf.getInstance();
}
}
示例7: TwitterJobManager
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public TwitterJobManager()
{
languageDetector = new LanguageDetector();
for(int i =0; i< twitKey.length; i++)
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(twitKey[i].getConsumer())
.setOAuthConsumerSecret(twitKey[i].getSecret())
.setOAuthAccessToken(twitKey[i].getAccess())
.setOAuthAccessTokenSecret(twitKey[i].getToken_secret());
TwitterFactory tf = new TwitterFactory(cb.build());
keys[i] = tf.getInstance();
}
}
示例8: TwitterSentimentJobManager
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public TwitterSentimentJobManager()
{
languageDetector = new LanguageDetector();
for(int i =0; i< twitKey.length; i++)
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(twitKey[i].getConsumer())
.setOAuthConsumerSecret(twitKey[i].getSecret())
.setOAuthAccessToken(twitKey[i].getAccess())
.setOAuthAccessTokenSecret(twitKey[i].getToken_secret());
TwitterFactory tf = new TwitterFactory(cb.build());
keys[i] = tf.getInstance();
}
}
示例9: execute
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(RubiconBot.getConfiguration().getString("twitterConsumerKey"))
.setOAuthConsumerSecret(RubiconBot.getConfiguration().getString("twitterConsumerSecret"))
.setOAuthAccessToken(RubiconBot.getConfiguration().getString("twitterAccessToken"))
.setOAuthAccessTokenSecret(RubiconBot.getConfiguration().getString("twitterAccessTokenSecret"));
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
try {
Status status = twitter.updateStatus(String.join(" ", parsedCommandInvocation.getArgs()));
parsedCommandInvocation.getMessage().getTextChannel().sendMessage(new EmbedBuilder()
.setDescription(status.getText())
.setColor(new Color(0, 153, 229))
.setAuthor("Take a look at the tweet on Twitter", "https://twitter.com/" + status.getUser().getScreenName() + "/status/" + status.getId(), "http://icons.iconarchive.com/icons/sicons/basic-round-social/512/twitter-icon.png")
.setFooter(new SimpleDateFormat("dd.MM.yyyy hh:mm:ss").format(status.getCreatedAt()), null)
.build()).queue();
} catch (TwitterException e) {
Logger.debug(e.getErrorMessage());
}
return null;
}
示例10: 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();
}
示例11: 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();
}
示例12: TwitterNotifier
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public TwitterNotifier() throws NotificationException {
super(CLIENT_ID, SECRET_ID,
PromptReceiver.class,
"com.yfiton.notifiers.twitter.TwitterWebEngineListener");
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder
.setGZIPEnabled(true)
.setDebugEnabled(true)
.setOAuthConsumerKey(getClientId())
.setOAuthConsumerSecret(getClientSecret());
com.yfiton.notifiers.twitter.AccessToken accessToken = getAccessToken();
if (accessToken != null) {
configurationBuilder.setOAuthAccessToken(accessToken.getAccessToken());
configurationBuilder.setOAuthAccessTokenSecret(accessToken.getAccessTokenSecret());
}
twitter =
new TwitterFactory(
configurationBuilder.build()).getInstance();
}
示例13: getTwitter
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public Twitter getTwitter() throws TwitterException, IOException
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(CONSUMER_KEY)
.setOAuthConsumerSecret(CONSUMER_SECRET)
.setOAuthAccessToken(ACCESS_TOKEN)
.setOAuthAccessTokenSecret(ACCESS_SECRET);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
twitter.setOAuthAccessToken(new AccessToken(ACCESS_TOKEN, ACCESS_SECRET));
return twitter;
}
示例14: getTwitter
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public Twitter getTwitter() throws TwitterException, IOException
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(CONSUMER_KEY)
.setOAuthConsumerSecret(CONSUMER_KEY_SECRET);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
twitter.setOAuthAccessToken(new AccessToken(ACCESS_TOKEN,
ACCESS_TOKEN_SECRET));
return twitter;
}
示例15: generateRunners
import twitter4j.conf.ConfigurationBuilder; //導入依賴的package包/類
public static SearchRunner[] generateRunners(
TwitterCredentials[] credentials,
QueryAssemblyStrategy qaStrategy,
ResultReceiver receiver
) throws TwitterException {
SearchRunner[] runners = new SearchRunner[credentials.length];
for (int i = 0; i < credentials.length; i++) {
Twitter connection = new TwitterFactory(
new ConfigurationBuilder()
.setOAuthConsumerKey(credentials[i].consumerKey)
.setOAuthConsumerSecret(credentials[i].consumerSecret)
.setOAuthAccessToken(credentials[i].token)
.setOAuthAccessTokenSecret(credentials[i].tokenSecret).build()
).getInstance();
runners[i] = new SearchRunner(connection, qaStrategy, receiver);
}
return runners;
}