Search in sources :

Example 21 with ConfigurationBuilder

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

the class DAOTest method getJSONArrayFromGetURL.

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

Example 22 with ConfigurationBuilder

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

the class ApplicationOnlyAuthTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    builder = new ConfigurationBuilder();
    builder.setApplicationOnlyAuthEnabled(true);
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder)

Example 23 with ConfigurationBuilder

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

the class ApplicationOnlyAuthTest method testSettingAccessToken1.

public void testSettingAccessToken1() 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);
    Twitter twitter = new TwitterFactory(cb.build()).getInstance();
    twitter.setOAuthConsumer(browserConsumerKey, browserConsumerSecret);
    twitter.setOAuth2Token(token);
    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 24 with ConfigurationBuilder

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

the class AuthorizationTest method testOAuth2Instance.

public void testOAuth2Instance() throws Exception {
    String consumerSecret = p.getProperty("browser.oauth.consumerSecret");
    String consumerKey = p.getProperty("browser.oauth.consumerSecret");
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setApplicationOnlyAuthEnabled(true);
    Twitter twitter = new TwitterFactory(cb.build()).getInstance();
    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    try {
        twitter.setOAuthConsumer(consumerSecret, consumerKey);
        fail("should throw IllegalStateException");
    } catch (IllegalStateException ignore) {
    }
    Authorization auth = twitter.getAuthorization();
    assertTrue(auth instanceof OAuth2Authorization);
}
Also used : Authorization(twitter4j.auth.Authorization) OAuth2Authorization(twitter4j.auth.OAuth2Authorization) OAuthAuthorization(twitter4j.auth.OAuthAuthorization) NullAuthorization(twitter4j.auth.NullAuthorization) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) OAuth2Authorization(twitter4j.auth.OAuth2Authorization)

Example 25 with ConfigurationBuilder

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

the class ApplicationOnlyAuthTest method testAuthWithPropertyFile.

public void testAuthWithPropertyFile() throws Exception {
    String filename = "./twitter4j.properties";
    try {
        // setup
        writeFile(filename, "enableApplicationOnlyAuth=true", "http.useSSL=true", "oauth.consumerKey=" + browserConsumerKey, "oauth.consumerSecret=" + browserConsumerSecret);
        // exercise
        Twitter twitter = new TwitterFactory(new ConfigurationBuilder().build()).getInstance();
        OAuth2Token token = twitter.getOAuth2Token();
        assertEquals("bearer", token.getTokenType());
        // 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