Search in sources :

Example 1 with ConfigurationBuilder

use of twitter4j.conf.ConfigurationBuilder in project Talon-for-Twitter by klinker24.

the class Utils method getTwitter.

public static Twitter getTwitter(Context context) {
    AppSettings settings = AppSettings.getInstance(context);
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.authenticationToken).setOAuthAccessTokenSecret(settings.authenticationTokenSecret);
    cb.setTweetModeExtended(true);
    TwitterFactory tf = new TwitterFactory(cb.build());
    return tf.getInstance();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) AppSettings(com.klinker.android.twitter.settings.AppSettings) TwitterFactory(twitter4j.TwitterFactory)

Example 2 with ConfigurationBuilder

use of twitter4j.conf.ConfigurationBuilder in project Talon-for-Twitter by klinker24.

the class Utils method getSecondTwitter.

public static Twitter getSecondTwitter(Context context) {
    AppSettings settings = AppSettings.getInstance(context);
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.secondAuthToken).setOAuthAccessTokenSecret(settings.secondAuthTokenSecret);
    TwitterFactory tf = new TwitterFactory(cb.build());
    return tf.getInstance();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) AppSettings(com.klinker.android.twitter.settings.AppSettings) TwitterFactory(twitter4j.TwitterFactory)

Example 3 with ConfigurationBuilder

use of twitter4j.conf.ConfigurationBuilder in project Talon-for-Twitter by klinker24.

the class Utils method getStreamingTwitter.

public static TwitterStream getStreamingTwitter(Context context, AppSettings settings) {
    settings = AppSettings.getInstance(context);
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.authenticationToken).setOAuthAccessTokenSecret(settings.authenticationTokenSecret);
    TwitterStreamFactory tf = new TwitterStreamFactory(cb.build());
    return tf.getInstance();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) TwitterStreamFactory(twitter4j.TwitterStreamFactory)

Example 4 with ConfigurationBuilder

use of twitter4j.conf.ConfigurationBuilder in project camel by apache.

the class TwitterConfiguration method getConfiguration.

/**
     * 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();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder)

Example 5 with ConfigurationBuilder

use of twitter4j.conf.ConfigurationBuilder in project twitter4j by yusuke.

the class ApplicationOnlyAuthTest method testSettingAccessTokenFromPropertyFile.

public void testSettingAccessTokenFromPropertyFile() throws Exception {
    String filename = "./twitter4j.properties";
    try {
        // setup
        builder.setOAuthConsumerKey(browserConsumerKey).setOAuthConsumerSecret(browserConsumerSecret);
        OAuth2Token token = new TwitterFactory(builder.build()).getInstance().getOAuth2Token();
        writeFile(filename, "enableApplicationOnlyAuth=true", "http.useSSL=true", "oauth.consumerKey=" + browserConsumerKey, "oauth.consumerSecret=" + browserConsumerSecret, "oauth2.tokenType=" + token.getTokenType(), "oauth2.accessToken=" + token.getAccessToken());
        Twitter twitter = new TwitterFactory(new ConfigurationBuilder().build()).getInstance();
        // exercise & verify
        Map<String, RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus("search");
        RateLimitStatus searchTweetsRateLimit = rateLimitStatus.get("/search/tweets");
        assertNotNull(searchTweetsRateLimit);
        assertEquals(searchTweetsRateLimit.getLimit(), 450);
    } finally {
        deleteFile(filename);
    }
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder)

Aggregations

ConfigurationBuilder (twitter4j.conf.ConfigurationBuilder)31 TwitterFactory (twitter4j.TwitterFactory)9 Configuration (twitter4j.conf.Configuration)4 TwitterStreamFactory (twitter4j.TwitterStreamFactory)3 AppSettings (com.klinker.android.twitter.settings.AppSettings)2 Map (java.util.Map)2 OAuth2Token (twitter4j.auth.OAuth2Token)2 OAuthAuthorization (twitter4j.auth.OAuthAuthorization)2 AlarmManager (android.app.AlarmManager)1 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 View (android.view.View)1 Animation (android.view.animation.Animation)1 CookieManager (android.webkit.CookieManager)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 TextView (android.widget.TextView)1 ViewSwitcher (android.widget.ViewSwitcher)1