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

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

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

Twitter.updateStatus介绍

[英]Updates the user's status. The text will be trimed if the length of the text is exceeding 160 characters.
This method calls http://twitter.com/statuses/update
[中]更新用户的状态。如果文本长度超过160个字符,文本将被修剪。
此方法调用http://twitter.com/statuses/update

代码示例

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

/**
 * To upload a picture with some piece of text.
 * 
 * 
 * @param file The file which we want to share with our tweet
 * @param message Message to display with picture
 * @param twitter Instance of authorized Twitter class
 * @throws Exception exception if any
 */

public void uploadPic(File file, String message,Twitter twitter) throws Exception  {
  try{
    StatusUpdate status = new StatusUpdate(message);
    status.setMedia(file);
    twitter.updateStatus(status);}
  catch(TwitterException e){
    Log.d("TAG", "Pic Upload error" + e.getErrorMessage());
    throw e;
  }
}

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

/**
 * To upload a picture with some piece of text.
 * 
 * 
 * @param file The file which we want to share with our tweet
 * @param message Message to display with picture
 * @param twitter Instance of authorized Twitter class
 * @throws Exception exception if any
 */

public void uploadPic(File file, String message,Twitter twitter) throws Exception  {
  try{
    StatusUpdate status = new StatusUpdate(message);
    status.setMedia(file);
    twitter.updateStatus(status);}
  catch(TwitterException e){
    Log.d("TAG", "Pic Upload error" + e.getErrorMessage());
    throw e;
  }
}

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

AccessToken accessToken = new AccessToken(token,secret);
Twitter twitter = new TwitterFactory().getOAuthAuthorizedInstance(consumerKey,consumerSecret,accessToken);
Status status = twitter.updateStatus("My First Status Update");
statusId = (int)status.getId();

代码示例来源:origin: org.apache.camel/camel-twitter

private Status updateStatus(StatusUpdate status) throws Exception {
  Status response = endpoint.getProperties().getTwitter().updateStatus(status);
  log.debug("Updated status: {}", status);
  log.debug("Status id: {}", response.getId());
  return response;
}

代码示例来源:origin: org.apache.camel/camel-twitter

private Status updateStatus(String status) throws Exception {
    Status response = endpoint.getProperties().getTwitter().updateStatus(status);
    log.debug("Updated status: {}", status);
    log.debug("Status id: {}", response.getId());
    return response;
  }
}

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

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    Status status = twitter.updateStatus(statusText);
    for (TwitterListener listener : listeners) {
      try {
        listener.updatedStatus(status);
      } catch (Exception e) {
        logger.warn("Exception at updatedStatus", e);
      }
    }
  }
});

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

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    Status status = twitter.updateStatus(latestStatus);
    for (TwitterListener listener : listeners) {
      try {
        listener.updatedStatus(status);
      } catch (Exception e) {
        logger.warn("Exception at updateStatus", e);
      }
    }
  }
});

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

try {
  AccessToken accessToken = new AccessToken(token,secret);
  Twitter twitter = new TwitterFactory().getOAuthAuthorizedInstance(consumerKey,consumerSecret,accessToken);
  shareText= edttweetnow.getText().toString();
  status = twitter.updateStatus(shareText);
  int statusId = (int)status.getId();

  Toast.makeText(TweetLoad.this, "Tweet Successfull", Toast.LENGTH_LONG).show();

} catch (TwitterException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
  Toast.makeText(TweetLoad.this, e.toString(), Toast.LENGTH_LONG).show();
}

代码示例来源: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

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

ConfigurationBuilder cb = new ConfigurationBuilder();
     cb.setDebugEnabled(true)
       .setOAuthConsumerKey(consumerKey)
       .setOAuthConsumerSecret(consumerSecret)
       .setOAuthAccessToken(oAuthAccessToken)
       .setOAuthAccessTokenSecret(oAuthAccessTokenSecret);
     TwitterFactory tf = new TwitterFactory(cb.build());
     Twitter twitter = tf.getInstance();
         twitter.updateStatus("This is a test message"); //ThrowsTwitterException

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

Twitter twitter= new TwitterFactory().getInstance();
twitter.setOAuthConsumer("************", "*************");
AccessToken newAccessToken = new AccessToken("******","*********");
System.out.println(newAccessToken);
twitter.setOAuthAccessToken(newAccessToken);
String s=twitter.getScreenName();
Status myStatus = twitter.updateStatus("Your message here");

代码示例来源: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

ConfigurationBuilder twitterConfigBuilder = new ConfigurationBuilder();
twitterConfigBuilder.setDebugEnabled(true);
twitterConfigBuilder.setOAuthConsumerKey("consumerkey");
twitterConfigBuilder.setOAuthConsumerSecret("consumersecret");
twitterConfigBuilder.setOAuthAccessToken("accesstoken");
twitterConfigBuilder.setOAuthAccessTokenSecret("accesstokensecret");

Twitter twitter = new TwitterFactory(twitterConfigBuilder.build()).getInstance();
String statusMessage = "Watch out this interesting offer I came across today";
File file = new File("/images/Done.jpg"); 

StatusUpdate status = new StatusUpdate(message);
status.setMedia(file); // set the image to be uploaded here.
twitter.updateStatus(status);

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

ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("YOUR_APP_KEY");
cb.setOAuthConsumerSecret("YOUR_APP_SECRET");
cb.setOAuthAccessToken("USER_TOKEN_KEY");
cb.setOAuthAccessTokenSecret("USER_TOKEN_SECRET");

Twitter twitter = new TwitterFactory(cb.build()).getInstance();   
String tweet="HELLO WORLD!";
twitter.updateStatus(tweet);

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

ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.setOAuthAccessToken("ACCESS_TOKEN");
   builder.setOAuthAccessTokenSecret("TOKEN_SECRET");
   builder.setOAuthConsumerKey("CLIENT_ID");
   builder.setOAuthConsumerSecret("CLIENT_SECRET");
   OAuthAuthorization auth = new OAuthAuthorization(builder.build());
   Twitter twitter = new TwitterFactory().getInstance(auth);
   twitter.updateStatus("TEXT TO POST");

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

ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

configurationBuilder.setOAuthConsumerKey(context.getResources().getString(R.string.twitter_consumer_key));

configurationBuilder.setOAuthConsumerSecret(context.getResources().getString(R.string.twitter_consumer_secret));

configurationBuilder.setOAuthAccessToken(LoginActivity.getAccessToken((context)));

configurationBuilder.setOAuthAccessTokenSecret(LoginActivity.getAccessTokenSecret(context));

Configuration configuration = configurationBuilder.build();

Twitter twitter = new TwitterFactory(configuration).getInstance();

StatusUpdate status = new StatusUpdate(message);

status.setMedia(file); // set the image to be uploaded here.

twitter.updateStatus(status);

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

ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

  configurationBuilder.setOAuthConsumerKey(context.getResources().getString(R.string.twitter_consumer_key));

   configurationBuilder.setOAuthConsumerSecret(context.getResources().getString(R.string.twitter_consumer_secret));

configurationBuilder.setOAuthAccessToken(LoginActivity.getAccessToken((context)));

configurationBuilder.setOAuthAccessTokenSecret(LoginActivity.getAccessTokenSecret(context));

Configuration configuration = configurationBuilder.build();

Twitter twitter = new TwitterFactory(configuration).getInstance();

StatusUpdate status = new StatusUpdate(message);

status.setMedia(file); // set the image to be uploaded here.

twitter.updateStatus(status);

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

private void replyTo(final Status status, final String reply, final boolean prefix) throws TwitterException {
  final String message;
  if (prefix) {
    message = "@" + status.getUser().getScreenName() + " " + reply;
  } else {
    message = reply;
  }
  final StatusUpdate statusUpdate = new StatusUpdate(message);
  statusUpdate.setInReplyToStatusId(status.getId());
  twitter.updateStatus(statusUpdate);
}

代码示例来源: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);
 }'

相关文章