twitter4j.Twitter.getOAuth2Token()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中twitter4j.Twitter.getOAuth2Token()方法的一些代码示例,展示了Twitter.getOAuth2Token()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Twitter.getOAuth2Token()方法的具体详情如下:
包路径:twitter4j.Twitter
类名称:Twitter
方法名:getOAuth2Token

Twitter.getOAuth2Token介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

ConfigurationBuilder builder=new ConfigurationBuilder();
     builder.setUseSSL(true);
     builder.setApplicationOnlyAuthEnabled(true);
     // setup
     Twitter twitter = new TwitterFactory(builder.build()).getInstance();
     // exercise & verify
     twitter.setOAuthConsumer(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
     // OAuth2Token token = twitter.getOAuth2Token();
     twitter.getOAuth2Token();
 statuses = twitter.getUserTimeline("Twitter");

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
public synchronized OAuth2Token getOAuth2Token() throws TwitterException {
  return twitter.getOAuth2Token();
}

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    OAuth2Token token = twitter.getOAuth2Token();
    for (TwitterListener listener : listeners) {
      try {
        listener.gotOAuth2Token(token);
      } catch (Exception e) {
      }
    }
  }
});

代码示例来源:origin: stackoverflow.com

// Use as field
Twitter twitter;

// Get timeline
try {
  if(twitter==null) {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(Constants.DEBUG)
        .setOAuthConsumerKey("YOUR CONSUMER KEY")
        .setOAuthConsumerSecret("YOUR CONSUMER SECRET")
        .setApplicationOnlyAuthEnabled(true)
        .setHttpConnectionTimeout(5000)
        .setHttpReadTimeout(5000)
        .setHttpStreamingReadTimeout(5000);
    twitter = new TwitterFactory(cb.build()).getInstance();
    twitter.getOAuth2Token();
  }
  return twitter.getUserTimeline("TwitterName", twitterPaging);
} catch (Exception e) {
  e.printStackTrace();
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

private TwitterClient createTwitterClientFromConfiguration(com.day.cq.wcm.webservicesupport.Configuration config) {
  Resource oauthConfig = config.getContentResource().listChildren().next();
  ValueMap oauthProps = oauthConfig.getValueMap();
  String consumerKey = oauthProps.get("oauth.client.id", String.class);
  String consumerSecret = oauthProps.get("oauth.client.secret", String.class);
  if (consumerKey != null && consumerSecret != null) {
    Twitter twitter = getInstance();
    log.debug("Creating client for key {}.", consumerKey);
    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    try {
      twitter.getOAuth2Token();
      return new TwitterClientImpl(twitter, config);
    } catch (TwitterException e) {
      log.error("Unable to create Twitter client.", e);
      return null;
    }
  } else {
    log.warn("Key or Secret missing for configuration {}", config.getPath());
  }
  return null;
}

相关文章