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

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

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

Twitter.setOAuthConsumer介绍

暂无

代码示例

代码示例来源: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 void setOAuthConsumer(String consumerKey, String consumerSecret) {
  twitter.setOAuthConsumer(consumerKey, consumerSecret);
}

代码示例来源:origin: jchampemont/WTFDYUM

private Twitter twitter() {
  final Twitter instance = twitterFactory.getInstance();
  instance.setOAuthConsumer(appId, appSecret);
  return instance;
}

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

AccessToken a = new AccessToken(token, secret);
   final Twitter twitter = new TwitterFactory().getInstance();
   twitter.setOAuthConsumer(Constants.CONSUMER_KEY,
       Constants.CONSUMER_SECRET);
   twitter.setOAuthAccessToken(a);

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

Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecret);
RequestToken requestToken = twitter.getOAuthRequestToken(CALLBACKURL); 
...
...

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

public static void sendTweet(SharedPreferences prefs,String msg) throws Exception {
  String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
  String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");

  AccessToken a = new AccessToken(token,secret);
  Twitter twitter = new TwitterFactory().getInstance();
  twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
  twitter.setOAuthAccessToken(a);
  twitter.updateStatus(msg);
}

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

Twitter twitter = new Twitter();
twitter.setOAuthConsumer(consumerKey,consumerSecret);
RequestToken requestToken = twitter.getOAuthRequestToken();

String token = requestToken.getToken();
String tokenSecret = requestToken.getTokenSecret();

HttpSession session = request.getSession();
session.setAttribute("token",token);
session.setAttribute("tokenSecret",tokenSecret);

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

public void sendTweet(SharedPreferences prefs,String msg) throws Exception {
  String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
  String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");

  AccessToken a = new AccessToken(token,secret); 

  Twitter twitter = new TwitterFactory().getInstance();
  twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
  twitter.setOAuthAccessToken(a);
  twitter.updateStatus(msg);
}

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

AccessToken a = new AccessToken(token,secret);
 Twitter twitter = new TwitterFactory().getInstance();
 twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
 twitter.setOAuthAccessToken(a);
 int i=twitter.getId();
 User u=twitter.showUser(i);
 System.out.println("user name"+u.getName());

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

TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);

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

Twitter twitter = new Twitter();
twitter.setOAuthConsumer(consumerKey,consumerSecret);
AccessToken accessToken =
  twitter.getOAuthAccessToken(token, tokenSecret);
twitter.setOAuthAccessToken(accessToken);

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

AccessToken a = new AccessToken(token,secret);
   Twitter twitter = new TwitterFactory().getInstance();
   twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
   twitter.setOAuthAccessToken(a);
   //Some information is available through method calls
   int myid=twitter.getId();
   String username=twitter.getScreenName();

代码示例来源:origin: org.tomitribe/chatterbox-twitter-impl

public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
  LOGGER.info("Starting " + this);
  client = new TwitterStreamingClient(this, consumerKey, consumerSecret, accessToken, accessTokenSecret);
  twitter = new TwitterFactory().getInstance();
  twitter.setOAuthConsumer(consumerKey, consumerSecret);
  twitter.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret));
  try {
    client.run();
  } catch (InterruptedException | ControlStreamException | IOException e) {
    e.printStackTrace();
  }
}

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

AccessToken twitterToken = objectDeserialization();
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(twitterApiKey, twitterApiSecret);
twitter.setOAuthAccessToken(new AccessToken(twitterToken.getToken(), twitterToken.getTokenSecret()));
twitter4j.Status status = twitter.updateStatus("This is sparta! :)");

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

Twitter twitter = new TwitterFactory().getInstance(twitter4JConfiguration);
twitter.setOAuthConsumer(consumerKey, consumerSecret);
twitter.setOAuthAccessToken(new AccessToken(oauthToken, oauthTokenSecret));
String screenName = twitter.getScreenName(); // Returns authenticating user's screen name.
User stephenfry = twitter.showUser("stephenfry"); // Returns extended information of a given user ...
List<User> friends = twitter.getFriendsList("stephenfry", -1L); // Returns a cursored collection of user objects ...

代码示例来源:origin: ORCID/ORCID-Source

/**
 * Get the twitter AccessToken
 * 
 * @return The twitter AccessToken
 * */
private AccessToken getOAuthAccessToken(String orcid, String pin) throws Exception {
  RequestToken requestToken = getTwitterRequestToken(orcid);
  Twitter twitter = new TwitterFactory().getInstance();
  twitter.setOAuthConsumer(twitterKey, twitterSecret);
  return twitter.getOAuthAccessToken(requestToken, pin);
}

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

Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer("yourConsumerKey","yourConsumerSecret");
RequestToken requestToken = twitter.getOAuthRequestToken();

session.setAttribute("token", requestToken.getToken());
session.setAttribute("tokenSecret", requestToken.getTokenSecret());

// REDIRECT USER TO TWITTER LOGIN PAGE

response.sendRedirect(requestToken.getAuthorizationURL());

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

public static void reply(long inReplyToStatusId,String text,double latitude,double longitude,TwitterFactory factory) throws TwitterException
{   AccessToken accessToken = loadAccessToken();
  Twitter twitter = factory.getInstance();
  twitter.setOAuthConsumer(consumerKey, consumerSecrate);
  twitter.setOAuthAccessToken(accessToken);

  StatusUpdate stat= new StatusUpdate(text);

  stat.setInReplyToStatusId(inReplyToStatusId);

  GeoLocation location= new GeoLocation(latitude, longitude);
  stat.setLocation(location);

  twitter.updateStatus(stat);
 }'

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

String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
AccessToken a = new AccessToken(token, secret);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey(yourConsumerKey).setOAuthConsumerSecret(yourConsumerSeceret).setOAuthAccessToken(yourAccessToken).setOAuthAccessTokenSecret(yourAccessTokenSeceret);
Configuration conf = cb.build();
ImageUploadFactory factory = new ImageUploadFactory(conf);
ImageUpload upload = factory.getInstance();
String url = upload.upload(yourImage, yourCaptionWithImage); //image is a File Format and Caption is String

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

String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
     String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
     AccessToken a = new AccessToken(token, secret);
     Twitter twitter = new TwitterFactory().getInstance();
     twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
     twitter.setOAuthAccessToken(a);
     ConfigurationBuilder cb = new ConfigurationBuilder();
     cb.setDebugEnabled(true).setOAuthConsumerKey(yourConsumerKey).setOAuthConsumerSecret(yourConsumerSeceret).setOAuthAccessToken(yourAccessToken).setOAuthAccessTokenSecret(yourAccessTokenSeceret);
     Configuration conf = cb.build();
     ImageUploadFactory factory = new ImageUploadFactory(conf);
     ImageUpload upload = factory.getInstance();
     String url = upload.upload(yourImage, yourCaptionWithImage); //image is a File Format and Caption is String

相关文章