Search in sources :

Example 91 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class DeleteUserListMember method main.

/**
     * Usage: java twitter4j.examples.list.DeleteUserListMember [list id] [user id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println("Usage: java twitter4j.examples.list.DeleteUserListMember [list id] [user id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.destroyUserListMember(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
        System.out.println("Successfully deleted user [" + args[1] + "] from the list.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to delete user: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 92 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class DestroyUserListSubscription method main.

/**
     * Usage: java twitter4j.examples.list.DestroyUserListSubscription [list id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.DestroyUserListSubscription [list id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.destroyUserListSubscription(Integer.parseInt(args[0]));
        System.out.println("Successfully unsubscribed the list.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to unsubscribe the list: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 93 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class ImgLyImageUpload method main.

/**
     * Usage: java twitter4j.examples.media.ImgLyImageUpload [image file path] [message]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.media.ImgLyImageUpload [image file path] [message]");
        System.exit(-1);
    }
    try {
        ImageUpload upload = new ImageUploadFactory().getInstance(MediaProvider.IMG_LY);
        String url;
        if (args.length >= 2) {
            url = upload.upload(new File(args[0]), args[1]);
        } else {
            url = upload.upload(new File(args[0]));
        }
        System.out.println("Successfully uploaded image to img.ly at " + url);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to upload the image: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : ImageUploadFactory(twitter4j.media.ImageUploadFactory) ImageUpload(twitter4j.media.ImageUpload) File(java.io.File) TwitterException(twitter4j.TwitterException)

Example 94 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class TwippleImageUpload method main.

/**
     * Usage: java twitter4j.examples.media.TwippleImageUpload [image file path] [message]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.media.TwippleImageUpload [image file path] [message]");
        System.exit(-1);
    }
    try {
        ImageUpload upload = new ImageUploadFactory().getInstance(MediaProvider.TWIPPLE);
        String url;
        if (args.length >= 2) {
            url = upload.upload(new File(args[0]), args[1]);
        } else {
            url = upload.upload(new File(args[0]));
        }
        System.out.println("Successfully uploaded image to Twipple at " + url);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to upload the image: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : ImageUploadFactory(twitter4j.media.ImageUploadFactory) ImageUpload(twitter4j.media.ImageUpload) File(java.io.File) TwitterException(twitter4j.TwitterException)

Example 95 with TwitterException

use of twitter4j.TwitterException in project intellij-community by JetBrains.

the class StudyTwitterUtils method createTwitterDialogAndShow.

public static void createTwitterDialogAndShow(@NotNull Project project, @NotNull final StudyTwitterPluginConfigurator configurator, @NotNull Task task) {
    ApplicationManager.getApplication().invokeLater(() -> {
        DialogWrapper.DoNotAskOption doNotAskOption = createDoNotAskOption(project, configurator);
        StudyTwitterUtils.TwitterDialogPanel panel = configurator.getTweetDialogPanel(task);
        if (panel != null) {
            TwitterDialogWrapper wrapper = new TwitterDialogWrapper(project, panel, doNotAskOption);
            wrapper.setDoNotAskOption(doNotAskOption);
            panel.addTextFieldVerifier(createTextFieldLengthDocumentListener(wrapper, panel));
            if (wrapper.showAndGet()) {
                try {
                    boolean isAuthorized = !configurator.getTwitterAccessToken(project).isEmpty();
                    Twitter twitter = getTwitter(configurator.getConsumerKey(project), configurator.getConsumerSecret(project));
                    if (!isAuthorized) {
                        authorizeAndUpdateStatus(project, twitter, panel);
                    } else {
                        setAuthInfoInTwitter(twitter, configurator.getTwitterAccessToken(project), configurator.getTwitterTokenSecret(project));
                        updateStatus(panel, twitter);
                    }
                } catch (TwitterException | IOException e) {
                    LOG.warn(e.getMessage());
                    Messages.showErrorDialog("Status wasn\'t updated. Please, check internet connection and try again", "Twitter");
                }
            } else {
                LOG.warn("Panel is null");
            }
        }
    });
}
Also used : Twitter(twitter4j.Twitter) IOException(java.io.IOException) TwitterException(twitter4j.TwitterException) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Aggregations

TwitterException (twitter4j.TwitterException)96 Twitter (twitter4j.Twitter)69 TwitterFactory (twitter4j.TwitterFactory)54 Status (twitter4j.Status)21 User (twitter4j.User)12 Intent (android.content.Intent)11 ArrayList (java.util.ArrayList)9 File (java.io.File)6 IDs (twitter4j.IDs)6 Context (android.content.Context)5 Date (java.util.Date)4 DirectMessage (twitter4j.DirectMessage)4 Paging (twitter4j.Paging)4 AccessToken (twitter4j.auth.AccessToken)4 Activity (android.app.Activity)3 SharedPreferences (android.content.SharedPreferences)3 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3