Example usage for twitter4j.auth AccessToken AccessToken

List of usage examples for twitter4j.auth AccessToken AccessToken

Introduction

In this page you can find the example usage for twitter4j.auth AccessToken AccessToken.

Prototype

public AccessToken(String token, String tokenSecret) 

Source Link

Usage

From source file:com.eclipsesource.iot.photosensor.example.Main.java

License:Open Source License

private static AccessToken loadAccessToken() {
    String token = Main.token;/*from   w  w  w .j a  va 2s  .co  m*/
    String tokenSecret = secret;
    return new AccessToken(token, tokenSecret);
}

From source file:com.firewallid.crawling.TwitterApp.java

private Twitter createTwitter() {
    String[] currentApp = conf.getStrings(String.format("%s.%s", APPS, apps[appIdx])); //0:CONSUMER_KEY 1:CONSUMER_KEY_SECRET 2:ACCESS_TOKEN 3:ACCESS_TOKEN_SECRET

    Twitter tw = new TwitterFactory().getInstance();
    tw.setOAuthConsumer(currentApp[0], currentApp[1]);
    AccessToken accessToken = new AccessToken(currentApp[2], currentApp[3]);
    tw.setOAuthAccessToken(accessToken);

    return tw;/* w  ww. j  a  v  a  2 s  .c om*/
}

From source file:com.freshdigitable.udonroad.module.twitter.TwitterApi.java

License:Apache License

@Nullable
public static AccessToken loadAccessToken(SharedPreferences sharedPreference) {
    String token = sharedPreference.getString(TOKEN, null);
    if (token == null) {
        return null;
    }/*from   w w w  . j  a v a2 s. c o  m*/
    String tokenSecret = sharedPreference.getString(TOKEN_SECRET, null);
    if (tokenSecret == null) {
        return null;
    }

    return new AccessToken(token, tokenSecret);
}

From source file:com.github.checkstyle.publishers.TwitterPublisher.java

License:Open Source License

/**
 * Publish post./*w  w  w  .  j av a2 s .c  o  m*/
 * @throws TwitterException if an error occurs while publishing.
 * @throws IOException if there are problems with reading file with the post text.
 */
public void publish() throws TwitterException, IOException {
    final Twitter twitter = new TwitterFactory().getInstance();
    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    final AccessToken token = new AccessToken(accessToken, accessTokenSecret);
    twitter.setOAuthAccessToken(token);
    final String post = new String(Files.readAllBytes(Paths.get(postFilename)), StandardCharsets.UTF_8);
    twitter.updateStatus(post);
}

From source file:com.github.gorbin.asne.twitter.TwitterSocialNetwork.java

License:Open Source License

private void initTwitterClient() {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthConsumerKey(fConsumerKey);
    builder.setOAuthConsumerSecret(fConsumerSecret);

    String accessToken = mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_TOKEN, null);
    String accessTokenSecret = mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_SECRET, null);

    TwitterFactory factory = new TwitterFactory(builder.build());

    if (TextUtils.isEmpty(accessToken) && TextUtils.isEmpty(accessTokenSecret)) {
        mTwitter = factory.getInstance();
    } else {/*from   w  w  w.  j a  v  a  2s  .  c  o  m*/
        mTwitter = factory.getInstance(new AccessToken(accessToken, accessTokenSecret));
    }
}

From source file:com.gloriouseggroll.TwitterAPI.java

License:Open Source License

public void loadAccessToken(String token, String tokenSecret) {
    this.access_token = new AccessToken(token, tokenSecret);
    twitter.setOAuthAccessToken(access_token);
}

From source file:com.gmail.altakey.joanne.service.TwitterAuthService.java

License:Apache License

public AccessToken getAccessToken() {
    final SharedPreferences prefs = getSharedPreferences(PREFERENCE, MODE_PRIVATE);
    final String token = prefs.getString(KEY_TOKEN, null);
    final String tokenSecret = prefs.getString(KEY_TOKEN_SECRET, null);
    if (token != null && tokenSecret != null) {
        return new AccessToken(token, tokenSecret);
    } else {/*from ww w .j  a va 2  s  .co m*/
        return null;
    }
}

From source file:com.google.appinventor.components.runtime.Twitter.java

License:Open Source License

private AccessToken retrieveAccessToken() {
    String token = sharedPreferences.getString(ACCESS_TOKEN_TAG, "");
    String secret = sharedPreferences.getString(ACCESS_SECRET_TAG, "");
    if (token.length() == 0 || secret.length() == 0) {
        return null;
    }/*from   w  w  w.  j  av a2  s . c o m*/
    return new AccessToken(token, secret);
}

From source file:com.hyperkode.friendshare.activities.TwitterList.java

License:Open Source License

private void setupTwitter() {
    mSettings = getSharedPreferences(PREFS_NAME, 0);
    accessToken = mSettings.getString("twitter_access_token", null);
    accessTokenSecret = mSettings.getString("twitter_access_token_secret", null);
    // Get Access Token and persist it  
    AccessToken at = new AccessToken(accessToken, accessTokenSecret);
    // initialize Twitter4J  
    twitter4j = new TwitterFactory().getInstance();
    twitter4j.setOAuthConsumer(getString(R.string.TWITTER_CONSUMER_KEY),
            getString(R.string.TWITTER_CONSUMER_SECRET));
    twitter4j.setOAuthAccessToken(at);//from  w  ww  .  j a  va 2  s.c om

}

From source file:com.hyperkode.friendshare.activities.TwitterMapViewActivity.java

License:Open Source License

private void setupTwitter() {
    mSettings = getSharedPreferences(PREFS_NAME, 0);
    accessToken = mSettings.getString("twitter_access_token", null);
    accessTokenSecret = mSettings.getString("twitter_access_token_secret", null);
    // Get Access Token and persist it  
    AccessToken at = new AccessToken(accessToken, accessTokenSecret);
    // initialize Twitter4J  
    twitter = new TwitterFactory().getInstance();
    twitter.setOAuthConsumer(getString(R.string.TWITTER_CONSUMER_KEY),
            getString(R.string.TWITTER_CONSUMER_SECRET));
    twitter.setOAuthAccessToken(at);//from  ww  w . jav  a  2  s  . c  om
}