Search in sources :

Example 6 with StatusUpdate

use of twitter4j.StatusUpdate in project mobile-android by photo.

the class TwitterFragment method sendTweet.

public static void sendTweet(String message, Twitter twitter) throws TwitterException {
    StatusUpdate update = new StatusUpdate(message);
    TrackerUtils.trackSocial("twitter", "status update", message);
    twitter.updateStatus(update);
}
Also used : StatusUpdate(twitter4j.StatusUpdate)

Example 7 with StatusUpdate

use of twitter4j.StatusUpdate in project twitter4j by yusuke.

the class UploadMultipleImages method main.

/**
     * Usage: java twitter4j.examples.tweets.UploadMultipleImages [text] [file1] [file2] ...
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.tweets.UploadMultipleImages [text] [file1] [file2] ...");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long[] mediaIds = new long[args.length - 1];
        for (int i = 1; i < args.length; i++) {
            System.out.println("Uploading...[" + i + "/" + (args.length - 1) + "][" + args[i] + "]");
            UploadedMedia media = twitter.uploadMedia(new File(args[i]));
            System.out.println("Uploaded: id=" + media.getMediaId() + ", w=" + media.getImageWidth() + ", h=" + media.getImageHeight() + ", type=" + media.getImageType() + ", size=" + media.getSize());
            mediaIds[i - 1] = media.getMediaId();
        }
        StatusUpdate update = new StatusUpdate(args[0]);
        update.setMediaIds(mediaIds);
        Status status = twitter.updateStatus(update);
        System.out.println("Successfully updated the status to [" + status.getText() + "][" + status.getId() + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to update status: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : StatusUpdate(twitter4j.StatusUpdate) Status(twitter4j.Status) UploadedMedia(twitter4j.UploadedMedia) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) File(java.io.File) TwitterException(twitter4j.TwitterException)

Example 8 with StatusUpdate

use of twitter4j.StatusUpdate in project Talon-for-Twitter by klinker24.

the class TwitLongerHelper method createPost.

/**
 * posts the status onto Twitlonger, it then posts the shortened status (with link) to the user's twitter and updates the status on twitlonger
 * to include the posted status's id.
 *
 * @return id of the status that was posted to twitter
 */
public long createPost() {
    TwitLongerStatus status = postToTwitLonger();
    long statusId;
    try {
        Status postedStatus;
        StatusUpdate update = new StatusUpdate(status.getText());
        if (replyToStatusId != 0) {
            update.setInReplyToStatusId(replyToStatusId);
        }
        if (location != null) {
            update.setLocation(location);
        }
        postedStatus = twitter.updateStatus(update);
        statusId = postedStatus.getId();
        updateTwitlonger(status, statusId);
    } catch (Exception e) {
        e.printStackTrace();
        statusId = 0;
    }
    // if zero, then it failed
    return statusId;
}
Also used : Status(twitter4j.Status) StatusUpdate(twitter4j.StatusUpdate)

Aggregations

StatusUpdate (twitter4j.StatusUpdate)8 Status (twitter4j.Status)4 InputStream (java.io.InputStream)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 TwitterException (twitter4j.TwitterException)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 Handler (android.os.Handler)1 ConnectionResult (com.google.android.gms.common.ConnectionResult)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1 PutDataMapRequest (com.google.android.gms.wearable.PutDataMapRequest)1 HandleScrollService (com.klinker.android.twitter.activities.launcher_page.HandleScrollService)1 AppSettings (com.klinker.android.twitter.settings.AppSettings)1 WearableUtils (com.klinker.android.twitter.utils.WearableUtils)1 TweetMarkerHelper (com.klinker.android.twitter.utils.api_helper.TweetMarkerHelper)1 BufferedInputStream (java.io.BufferedInputStream)1