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);
}
}
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);
}
}
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);
}
}
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);
}
}
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");
}
}
});
}
Aggregations