Search in sources :

Example 6 with ConfigurationBuilder

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

the class OAuthTest method testOAuth.

public void testOAuth() throws Exception {
    ConfigurationBuilder build = new ConfigurationBuilder();
    String oAuthAccessToken = p.getProperty("id1.oauth.accessToken");
    String oAuthAccessTokenSecret = p.getProperty("id1.oauth.accessTokenSecret");
    String oAuthConsumerKey = p.getProperty("oauth.consumerKey");
    String oAuthConsumerSecret = p.getProperty("oauth.consumerSecret");
    build.setOAuthAccessToken(oAuthAccessToken);
    build.setOAuthAccessTokenSecret(oAuthAccessTokenSecret);
    build.setOAuthConsumerKey(oAuthConsumerKey);
    build.setOAuthConsumerSecret(oAuthConsumerSecret);
    OAuthAuthorization auth = new OAuthAuthorization(build.build());
    Twitter twitter = new TwitterFactory().getInstance(auth);
    twitter.verifyCredentials();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder)

Example 7 with ConfigurationBuilder

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

the class ApplicationOnlyAuthTest method testSettingAccessToken2.

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

Example 8 with ConfigurationBuilder

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

the class DAOTest method getJSONObjectFromPostURL.

private JSONObject getJSONObjectFromPostURL(String url) throws Exception {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setUser(id1.screenName);
    builder.setPassword(id1.password);
    return getJSONObjectFromPostURL(url, builder.build());
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder)

Example 9 with ConfigurationBuilder

use of twitter4j.conf.ConfigurationBuilder in project opennms by OpenNMS.

the class MicroblogClient method getTwitter.

public Twitter getTwitter(final String profile) {
    final MicroblogProfile mp = getProfile(profile);
    final ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setClientURL(mp.getServiceUrl());
    if (!isEmpty(mp.getOauthConsumerKey()))
        builder.setOAuthConsumerKey(mp.getOauthConsumerKey().orElse(null));
    if (!isEmpty(mp.getOauthConsumerSecret()))
        builder.setOAuthConsumerSecret(mp.getOauthConsumerSecret().orElse(null));
    if (!isEmpty(mp.getOauthAccessToken()))
        builder.setOAuthAccessToken(mp.getOauthAccessToken().orElse(null));
    if (!isEmpty(mp.getOauthAccessTokenSecret()))
        builder.setOAuthAccessTokenSecret(mp.getOauthAccessTokenSecret().orElse(null));
    if (!isEmpty(mp.getAuthenUsername()))
        builder.setUser(mp.getAuthenUsername().orElse(null));
    if (!isEmpty(mp.getAuthenPassword()))
        builder.setPassword(mp.getAuthenPassword().orElse(null));
    return new TwitterFactory(builder.build()).getInstance();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) MicroblogProfile(org.opennms.netmgt.config.microblog.MicroblogProfile) TwitterFactory(twitter4j.TwitterFactory)

Example 10 with ConfigurationBuilder

use of twitter4j.conf.ConfigurationBuilder in project tdi-studio-se by Talend.

the class TwitterLoad method twitterStream.

public static JavaDStream<List<Object>> twitterStream(JavaStreamingContext ctx, String username, String password, String accessToken, String secretToken, String[] filters, List<TwitterParameter> twitterParameters) {
    twitter4j.conf.ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthAccessToken(accessToken);
    builder.setOAuthAccessTokenSecret(secretToken);
    builder.setOAuthConsumerKey(username);
    builder.setOAuthConsumerSecret(password);
    JavaDStream<Status> inputDStream = null;
    if (filters.length > 0) {
        if (filters.length == 1 && filters[0].equals(""))
            inputDStream = TwitterUtils.createStream(ctx, new OAuthAuthorization(builder.build()));
        else
            inputDStream = TwitterUtils.createStream(ctx, new OAuthAuthorization(builder.build()), filters);
        return inputDStream.map(new LoadTwitterFunction(twitterParameters));
    }
    return null;
}
Also used : Status(twitter4j.Status) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) LoadTwitterFunction(org.talend.spark.function.LoadTwitterFunction) OAuthAuthorization(twitter4j.auth.OAuthAuthorization)

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