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


Java ConfigurationBuilder.setDebugEnabled方法代碼示例

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


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

示例1: 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);
}
 
開發者ID:almightyGOSU,項目名稱:CZ4045-NLP-Crawler,代碼行數:26,代碼來源:Twitter4JTesting.java

示例2: 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;
}
 
開發者ID:ganeshjawahar,項目名稱:ire-seimp,代碼行數:17,代碼來源:TwitterManager.java

示例3: 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);
  }
}
 
開發者ID:OpenLiberty,項目名稱:sample-acmegifts,代碼行數:39,代碼來源:NotificationResource.java

示例4: 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();
            }
        }
    }
 
開發者ID:saveendhiman,項目名稱:BackgroundTwitterSharing,代碼行數:29,代碼來源:TwitterSharingActivity.java

示例5: TweetInfo

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public TweetInfo(int MaxCount, File englishStopwordsFile, String OAuthConsumerKey,
		String OAUTHConsumerSecret,
		String OAUTHAccessToken,
		String OAUTHAccessTokenSecret) throws XMLStreamException, IOException
{
	this.maxCount=MaxCount;
             //endTime=LocalTime.now().getMinute()+2;
             xg=new XmlGenerator(englishStopwordsFile);
      cb=new ConfigurationBuilder();
      cb.setDebugEnabled(true);
      cb.setOAuthConsumerKey("yJfMtMvwBo8ygMXW6C53nIiai");
      cb.setOAuthConsumerSecret("YaO21MifLQVBlPTPCkgL7iBEk3CrtpsViaVE4B6Dsriss3Z1QM");
      cb.setOAuthAccessToken("704646632747331584-LNRXY9JmLaAxbPyrIknf1eh6Dxc6ggF");
      cb.setOAuthAccessTokenSecret("gGmwmnmpbkO3eZmBpXjRnuF5sMqGWhxASu49RFm9H5Saz");
}
 
開發者ID:unsw-cse-soc,項目名稱:Data-curation-API,代碼行數:16,代碼來源:TweetInfo.java

示例6: loadAccessTwitter

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private Pair<TwitterStream, Twitter> loadAccessTwitter(String token, String tokenSecret, String consumerKey, String consumerSecret) {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);
    cb.setOAuthConsumerKey(consumerKey);
    cb.setOAuthConsumerSecret(consumerSecret);
    cb.setOAuthAccessToken(token);
    cb.setOAuthAccessTokenSecret(tokenSecret);
    Configuration authConf = cb.build();
    return new Pair(new TwitterStreamFactory(authConf).getInstance(), new TwitterFactory(authConf).getInstance());
}
 
開發者ID:NotAVeryIntelligentSystem,項目名稱:NARVIS,代碼行數:11,代碼來源:AccessTwitter.java

示例7: main

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String args[]) {
    CommandLineParser parser = new BasicParser();
    Options options = Sketch.getOptions();
    CommandLine line;

    try {
        line = parser.parse(options, args);
    } catch(ParseException exp) {
        System.err.println(exp.getMessage());

        Sketch.printHelp(options);
        return;
    }

    if (line.hasOption('h')) {
        Sketch.printHelp(options);
        return;
    }

    Sketch sketch = new Sketch();

    // Configuration for the Twitter API
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);
    cb.setOAuthConsumerKey(line.getOptionValue("k"));
    cb.setOAuthConsumerSecret(line.getOptionValue("s"));
    cb.setOAuthAccessToken(line.getOptionValue("t"));
    cb.setOAuthAccessTokenSecret(line.getOptionValue("S"));

    sketch.setConfiguration(cb.build());

    String[] leftOverArgs = new String[] { "--full-screen", line.getOptionValue("name", Sketch.class.getName()) };
    PApplet.concat(leftOverArgs, line.getArgs());

    PApplet.runSketch(leftOverArgs, sketch);
}
 
開發者ID:lennerd,項目名稱:TwitterGraph,代碼行數:37,代碼來源:Sketch.java

示例8: setCB

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public static ConfigurationBuilder setCB()
{
	ConfigurationBuilder cb = new ConfigurationBuilder();
	
	cb.setDebugEnabled(true);
	cb.setOAuthConsumerKey("GQ4KveeL45kZvX4wnQXVrhRAs");
	cb.setOAuthConsumerSecret("RU67euqxYe6ZFZK5RR5lh5nukwP49Ah33qKD6CFbcTDL8XyUcO");
	
	return cb;
}
 
開發者ID:Monorail,項目名稱:ChallengeYourFriends,代碼行數:11,代碼來源:test.java

示例9: getTwitterInstance

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public static Twitter getTwitterInstance()
{
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(false);
    cb.setOAuthConsumerKey(TwitterCredentials.CONSUMER_KEY);
    cb.setOAuthConsumerSecret(TwitterCredentials.CONSUMER_SECRET);
    cb.setOAuthAccessToken(TwitterCredentials.ACCESS_TOKEN);
    cb.setOAuthAccessTokenSecret(TwitterCredentials.ACCESS_TOKEN_SECRET);
    TwitterFactory tf = new TwitterFactory(cb.build());
    return tf.getInstance();
}
 
開發者ID:spupyrev,項目名稱:swcv,代碼行數:12,代碼來源:TwitterReader.java

示例10: getConf

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public static Configuration getConf(String consumerKey, String consumerSecret) {
    ConfigurationBuilder conf = new ConfigurationBuilder();
    conf.setOAuthConsumerKey(consumerKey);
    conf.setOAuthConsumerSecret(consumerSecret);
    conf.setDebugEnabled(true);
    return conf.build();
}
 
開發者ID:lacolaco,項目名稱:SmileEssence,代碼行數:8,代碼來源:TwitterApi.java

示例11: connect

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
public void connect(){

		ConfigurationBuilder cb = new ConfigurationBuilder();
		cb.setDebugEnabled(true);
		cb.setOAuthConsumerKey(Colours.consumerKeyTwitter);
		cb.setOAuthConsumerSecret(Colours.consumerSecretTwitter);
		cb.setOAuthAccessToken(Colours.tokenTwitter);
		cb.setOAuthAccessTokenSecret(Colours.tokenSecretTwitter);
		cb.setHttpConnectionTimeout(sketch.TIMEOUT);
		cb.setHttpReadTimeout(sketch.TIMEOUT);
		cb.setHttpStreamingReadTimeout(sketch.TIMEOUT);
		TwitterFactory tf = new TwitterFactory(cb.build());
		sketch.twitter = tf.getInstance();
	}
 
開發者ID:vialab,項目名稱:TandemTable,代碼行數:15,代碼來源:TwitterGetter.java

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

示例13: createConfiguration

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
private static Configuration createConfiguration() {
    final org.tweetwallfx.config.Configuration tweetWallFxConfig = org.tweetwallfx.config.Configuration.getInstance();
    final TwitterSettings twitterSettings = org.tweetwallfx.config.Configuration.getInstance()
            .getConfigTyped(TwitterSettings.CONFIG_KEY, TwitterSettings.class);

    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setDebugEnabled(twitterSettings.isDebugEnabled());
    builder.setTweetModeExtended(twitterSettings.isExtendedMode());

    TwitterSettings.OAuth twitterOAuthSettings = twitterSettings.getOauth();
    builder.setOAuthConsumerKey(twitterOAuthSettings.getConsumerKey());
    builder.setOAuthConsumerSecret(twitterOAuthSettings.getConsumerSecret());
    builder.setOAuthAccessToken(twitterOAuthSettings.getAccessToken());
    builder.setOAuthAccessTokenSecret(twitterOAuthSettings.getAccessTokenSecret());

    // optional proxy settings
    tweetWallFxConfig.getConfigTypedOptional(ConnectionSettings.CONFIG_KEY, ConnectionSettings.class)
            .map(ConnectionSettings::getProxy)
            .filter(proxy -> Objects.nonNull(proxy.getHost()) && !proxy.getHost().isEmpty())
            .ifPresent(proxy -> {
                builder.setHttpProxyHost(proxy.getHost());
                builder.setHttpProxyPort(proxy.getPort());
                builder.setHttpProxyUser(proxy.getUser());
                builder.setHttpProxyPassword(proxy.getPassword());
            });

    Configuration conf = builder.build();

    // check Configuration
    if (conf.getOAuthConsumerKey() != null && !conf.getOAuthConsumerKey().isEmpty()
            && conf.getOAuthConsumerSecret() != null && !conf.getOAuthConsumerSecret().isEmpty()
            && conf.getOAuthAccessToken() != null && !conf.getOAuthAccessToken().isEmpty()
            && conf.getOAuthAccessTokenSecret() != null && !conf.getOAuthAccessTokenSecret().isEmpty()) {
        Twitter twitter = new TwitterFactory(conf).getInstance();
        try {
            User user = twitter.verifyCredentials();
            LOGGER.info("User " + user.getName() + " validated");
        } catch (TwitterException ex) {
            EXCEPTION.set(ex);
            //  statusCode=400, message=Bad Authentication data -> wrong token
            //  statusCode=401, message=Could not authenticate you ->wrong consumerkey
            int statusCode = ex.getStatusCode();
            LOGGER.error("Error statusCode=" + statusCode + " " + (statusCode > 0 ? ex.getErrorMessage() : ex.getMessage()));
            conf = null;
        }
    } else {
        EXCEPTION.set(new IllegalStateException("Missing credentials!"));
    }

    return conf;
}
 
開發者ID:TweetWallFX,項目名稱:TweetwallFX,代碼行數:52,代碼來源:TwitterOAuth.java

示例14: open

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
public void open() throws EventException {
    super.open();
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(false);

    twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
    StatusListener listener = new StatusListener() {
        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        @Override
        public void onException(Exception ex) {
            ex.printStackTrace();
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
        }

        @Override
        public void onStallWarning(StallWarning warning) {
        }

        @Override
        public void onStatus(Status status) {
            HashtagEntity[] hashtagEntities = status.getHashtagEntities();
            
            JetstreamEvent event = new JetstreamEvent();
            event.setEventType("TwitterSample");

            Place place = status.getPlace();
            if (place != null) {
                event.put("country", place.getCountry());
            }
            event.put("ct", status.getCreatedAt().getTime());
            event.put("text", status.getText());
            event.put("lang", status.getLang());
            event.put("user", status.getUser().getName());
            if (hashtagEntities != null && hashtagEntities.length > 0) {
                StringBuilder s = new StringBuilder();
                s.append(hashtagEntities[0].getText());
                
                for (int i = 1; i < hashtagEntities.length; i++) {
                    s.append(",");
                    s.append(hashtagEntities[i].getText());
                }
                
                event.put("hashtag", s.toString());
            }

            fireSendEvent(event);
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }
    };
    twitterStream.addListener(listener);
    twitterStream.sample(); 
}
 
開發者ID:pulsarIO,項目名稱:realtime-analytics,代碼行數:63,代碼來源:TwitterSampleChannel.java

示例15: reconnect

import twitter4j.conf.ConfigurationBuilder; //導入方法依賴的package包/類
@Override
public boolean reconnect() {
	boolean result = false;
	final String cSecret = CustomPortalServiceHandler
	        .getConfigValue(E_ConfigKey.SOCIAL_TW_CS);
	final String cKey = CustomPortalServiceHandler
	        .getConfigValue(E_ConfigKey.SOCIAL_TW_CK);
	final String aToken = CustomPortalServiceHandler
	        .getConfigValue(E_ConfigKey.SOCIAL_TW_AT);
	final String aSecret = CustomPortalServiceHandler
	        .getConfigValue(E_ConfigKey.SOCIAL_TW_ATS);

	if (cKey != null && cSecret != null && aToken != null
	        && aSecret != null && cKey.trim().length() > 0
	        && cSecret.trim().length() > 0 && aToken.trim().length() > 0
	        && aSecret.trim().length() > 0) {
		System.setProperty("twitter4j.loggerFactory",
		        "twitter4j.NullLoggerFactory");
		final ConfigurationBuilder builder = new ConfigurationBuilder();
		builder.setOAuthAccessToken(aToken);
		builder.setOAuthAccessTokenSecret(aSecret);
		builder.setOAuthConsumerKey(cKey);
		builder.setOAuthConsumerSecret(cSecret);
		builder.setDebugEnabled(false);

		final TwitterFactory factory = new TwitterFactory(builder.build());
		/* AccessToken accessToken = new AccessToken(aToken, aSecret); */
		this.m_objTwitter = factory.getInstance();
		/*
		 * m_objTwitter.setOAuthConsumer(cKey, cSecret);
		 * m_objTwitter.setOAuthAccessToken(accessToken);
		 */
		try {
			this.m_objTwitter.getUserTimeline();
			result = true;
			this.m_bConnected = true;
		} catch (final TwitterException e) {
			m_objLog.warn(e);
		}
	}
	return result;

}
 
開發者ID:fraunhoferfokus,項目名稱:particity,代碼行數:44,代碼來源:TwitterClient.java


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