本文整理匯總了Java中twitter4j.conf.ConfigurationBuilder.setOAuthAccessTokenSecret方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationBuilder.setOAuthAccessTokenSecret方法的具體用法?Java ConfigurationBuilder.setOAuthAccessTokenSecret怎麽用?Java ConfigurationBuilder.setOAuthAccessTokenSecret使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twitter4j.conf.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.setOAuthAccessTokenSecret方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: getConfiguration
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* Builds a Twitter4J Configuration using the OAuth params.
*
* @return Configuration
*/
public Configuration getConfiguration() {
checkComplete();
ConfigurationBuilder confBuilder = new ConfigurationBuilder();
confBuilder.setOAuthConsumerKey(consumerKey);
confBuilder.setOAuthConsumerSecret(consumerSecret);
confBuilder.setOAuthAccessToken(accessToken);
confBuilder.setOAuthAccessTokenSecret(accessTokenSecret);
if (getHttpProxyHost() != null) {
confBuilder.setHttpProxyHost(getHttpProxyHost());
}
if (getHttpProxyUser() != null) {
confBuilder.setHttpProxyHost(getHttpProxyUser());
}
if (getHttpProxyPassword() != null) {
confBuilder.setHttpProxyHost(getHttpProxyPassword());
}
if (httpProxyPort != null) {
confBuilder.setHttpProxyPort(httpProxyPort);
}
return confBuilder.build();
}
示例6: main
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey("P9sUs46f03m4xAJZzxt7Q");
cb.setOAuthConsumerSecret("Czw2g7QoURXz5WoLE8AbMounBiVAONktlQP1YleEy0");
cb.setOAuthAccessToken("182798423-gFyyrktqZmcrTu916G7zTkNX3pnTsB8Zc4s22dOc");
cb.setOAuthAccessTokenSecret("ITKJnDENspq5dVZIQMjTtG4NOj2ioT0QE2DkE9ZZA");
TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
CStreamListener objStreamListener = new CStreamListener();
FilterQuery fq = new FilterQuery();
String [] keywords = TwitterConst.KEYWORDS;
fq.track(keywords);
twitterStream.addListener(objStreamListener);
twitterStream.filter(fq);
}
示例7: connect
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void connect() throws TwitterException {
initProperties();
ConfigurationBuilder config = new ConfigurationBuilder();
config.setOAuthConsumerKey(getOauthKey());
config.setOAuthConsumerSecret(getOauthSecret());
config.setOAuthAccessToken(getToken());
config.setOAuthAccessTokenSecret(getTokenSecret());
twitter4j.Twitter twitter = new TwitterFactory(config.build()).getInstance();
User user = twitter.verifyCredentials();
if (!this.userName.equals(user.getScreenName())) {
this.userName = user.getScreenName();
saveProperties(null);
}
//AccessToken accessToken = new AccessToken(getToken(), getTokenSecret());
//twitter4j.Twitter twitter = new TwitterFactory().getInstance(accessToken);
//twitter4j.Twitter twitter = new TwitterFactory().getInstance(getOauthKey(), getOauthSecret(), accessToken);
//twitter4j.Twitter twitter = new TwitterFactory().getInstance(getUsername(), getPassword());
setConnection(twitter);
}
示例8: TimelineStream
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* <p>
* Creates a new {@code TimelineStream} instance with the given OAuth
* information to use for collection.
* </p>
*
* @param consumerKey
* the Twitter consumer key to use
* @param consumerSecret
* the Twitter consumer secret to use
* @param accessToken
* the Twitter access token to use
* @param accessTokenSecret
* the Twitter access token secret to use
*/
public TimelineStream(String consumerKey, String consumerSecret,
String accessToken, String accessTokenSecret) {
this.setShouldShutdown(false);
this.setShutdownWhenEmpty(false);
this.userIds = new LinkedBlockingQueue<Long>();
this.listeners = new HashSet<TimelineStreamListener>();
// get oauth -> build twitter collection object
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(consumerKey);
cb.setOAuthConsumerSecret(consumerSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(accessTokenSecret);
// (timeout from original TLC code)
cb.setHttpConnectionTimeout(40000);
this.twitter = new TwitterFactory(cb.build()).getInstance();
}
示例9: verifyTwitterCredentials
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
protected boolean verifyTwitterCredentials()
{
Twitter twitter;
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(mOAuthData.getConsumerKey());
cb.setOAuthConsumerSecret(mOAuthData.getConsumerSecret());
cb.setOAuthAccessToken(mOAuthData.getAccessToken());
cb.setOAuthAccessTokenSecret(mOAuthData.getAccessTokenSecret());
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
try {
User user = twitter.verifyCredentials();
return true;
} catch (TwitterException te) {
return false;
}
}
示例10: init
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
/**
* Initializes this gateway
*/
@Override
@SuppressWarnings("rawtypes")
public void init(final GatewayEngine engine, final String id, final String cfcPath, final Map config) throws IOException
{
try
{
this.argType = ArgumentType.fromConfigValue((String) config.get(ARGUMENT_TYPE));
final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey((String) config.get(OAUTH_CONSUMER_KEY));
cb.setOAuthConsumerSecret((String) config.get(OAUTH_CONSUMER_SECRET));
cb.setOAuthAccessToken((String) config.get(OAUTH_ACCESS_TOKEN));
cb.setOAuthAccessTokenSecret((String) config.get(OAUTH_ACCESS_SECRET));
cb.setUserStreamRepliesAllEnabled(Boolean.valueOf((String) config.get(ALL_REPLIES)));
cb.setJSONStoreEnabled(ArgumentType.JSON.equals(this.argType));
super.init(engine, id, new TwitterUserStream(this, cb.build()));
}
catch (Throwable t)
{
final IOException ex = new IOException("Unable to initialize gateway", t);
this.onException(ex);
throw ex;
}
}
示例11: configure
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
public void configure(Properties props) {
ProducerConfig config = new ProducerConfig(props);
producer = new Producer<String, String>(config);
// The necessary authentication keys to connect to twitter API v1.1
String consumerKey = props.getProperty(TwitterProducerConstants.CONSUMER_KEY_KEY);
String consumerSecret = props.getProperty(TwitterProducerConstants.CONSUMER_SECRET_KEY);
String accessToken = props.getProperty(TwitterProducerConstants.ACCESS_TOKEN_KEY);
String accessTokenSecret = props.getProperty(TwitterProducerConstants.ACCESS_TOKEN_SECRET_KEY);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(consumerKey);
cb.setOAuthConsumerSecret(consumerSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(accessTokenSecret);
cb.setJSONStoreEnabled(true);
cb.setIncludeEntitiesEnabled(true);
twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
}
示例12: getTwitter
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private static Twitter getTwitter(HandlerContext handlerContext) {
Twitter res = (Twitter) handlerContext.get("twitter");
if (res == null) {
TwitterLinksHandlerConfig twitterLinksHandlerConfig = (TwitterLinksHandlerConfig) handlerContext.getHandlerConfig();
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setDebugEnabled(true).setOAuthConsumerKey(twitterLinksHandlerConfig.getOauthConsumerKey());
configurationBuilder.setOAuthConsumerSecret(twitterLinksHandlerConfig.getOauthConsumerSecret());
configurationBuilder.setOAuthAccessToken(twitterLinksHandlerConfig.getOauthAccessToken());
configurationBuilder.setOAuthAccessTokenSecret(twitterLinksHandlerConfig.getOauthAccessTokenSecret());
TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build());
res = twitterFactory.getInstance();
handlerContext.put("twitter", res);
}
return res;
}
示例13: getTwitter
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private static Twitter getTwitter(HandlerContext handlerContext) {
Twitter res = (Twitter) handlerContext.get("twitter");
if (res == null) {
TwitterFollowHandlerConfig twitterFollowHandlerConfig = (TwitterFollowHandlerConfig) handlerContext.getHandlerConfig();
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setDebugEnabled(true).setOAuthConsumerKey(twitterFollowHandlerConfig.getOauthConsumerKey());
configurationBuilder.setOAuthConsumerSecret(twitterFollowHandlerConfig.getOauthConsumerSecret());
configurationBuilder.setOAuthAccessToken(twitterFollowHandlerConfig.getOauthAccessToken());
configurationBuilder.setOAuthAccessTokenSecret(twitterFollowHandlerConfig.getOauthAccessTokenSecret());
TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build());
res = twitterFactory.getInstance();
handlerContext.put("twitter", res);
}
return res;
}
示例14: init
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@PostConstruct
public void init() {
try {
File log = new File(logFile);
File parentDir = log.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
FileHandler fh = new FileHandler(logFile);
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
File fbLog = new File(fallbackLogFile);
File fbParentDir = fbLog.getParentFile();
if (!fbParentDir.exists()) {
fbParentDir.mkdirs();
}
FileHandler fbFh = new FileHandler(fallbackLogFile);
fbLogger.addHandler(fbFh);
SimpleFormatter fbFormatter = new SimpleFormatter();
fbFh.setFormatter(fbFormatter);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setTweetModeExtended(true);
cb.setOAuthConsumerKey(consumerKey);
cb.setOAuthConsumerSecret(consumeSecret);
cb.setOAuthAccessToken(accessToken);
cb.setOAuthAccessTokenSecret(acessSecret);
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
} catch (Exception e) {
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
示例15: uploadToTwitter
import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void uploadToTwitter(String filePath, String title) {
int SDK_INT = android.os.Build.VERSION.SDK_INT;
if (SDK_INT > 8)
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
//your codes here
ConfigurationBuilder twitterConfigBuilder = new ConfigurationBuilder();
twitterConfigBuilder.setDebugEnabled(true);
twitterConfigBuilder.setOAuthConsumerKey(MainApplication.TWITTER_KEY);
twitterConfigBuilder.setOAuthConsumerSecret(MainApplication.TWITTER_SECRET);
twitterConfigBuilder.setOAuthAccessToken(TwitterCore.getInstance().getSessionManager().getActiveSession().getAuthToken().token);
twitterConfigBuilder.setOAuthAccessTokenSecret(TwitterCore.getInstance().getSessionManager().getActiveSession().getAuthToken().secret);
Twitter twitter = new TwitterFactory(twitterConfigBuilder.build()).getInstance();
File file = new File(filePath);
StatusUpdate status = new StatusUpdate(title);
status.setMedia(file); // set the image to be uploaded here.
try {
twitter.updateStatus(status);
} catch (twitter4j.TwitterException e) {
e.printStackTrace();
}
}
}