Permalink
Browse files

Merge branch 'master' of https://github.com/Mocel/twitter4j into TFJ-593

  • Loading branch information...
2 parents f5f336d + 22f8cf6 commit 665ae1d9d209853b5d752048704eef0467518dab Yusuke Yamamoto committed Oct 22, 2011
@@ -580,6 +580,82 @@ public void invoke(List<TwitterListener> listeners) throws TwitterException {
/**
* {@inheritDoc}
*/
+ public void updateStatusWithMedia(final String statusText,
+ final boolean possiblySensitive, final File file) {
+ getDispatcher().invokeLater(new AsyncTask(UPDATE_STATUS_WITH_MEDIA, listeners) {
+ @Override
+ void invoke(List<TwitterListener> listeners) throws TwitterException {
+ Status status = twitter.updateStatusWithMedia(statusText, possiblySensitive, file);
+ for (TwitterListener listener : listeners) {
+ try {
+ listener.updatedStatusWithMedia(status);
+ } catch (Exception ignore) {
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateStatusWithMedia(final String statusText, final boolean possiblySensitive,
+ final String mediaFilename, final InputStream mediaBody) {
+ getDispatcher().invokeLater(new AsyncTask(UPDATE_STATUS_WITH_MEDIA, listeners) {
+ @Override
+ void invoke(List<TwitterListener> listeners) throws TwitterException {
+ Status status = twitter.updateStatusWithMedia(statusText, possiblySensitive, mediaFilename, mediaBody);
+ for (TwitterListener listener : listeners) {
+ try {
+ listener.updatedStatusWithMedia(status);
+ } catch (Exception ignore) {
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateStatusWithMedia(final StatusUpdate latestStatus,
+ final boolean possiblySensitive, final File file) {
+ getDispatcher().invokeLater(new AsyncTask(UPDATE_STATUS_WITH_MEDIA, listeners) {
+ @Override
+ void invoke(List<TwitterListener> listeners) throws TwitterException {
+ Status status = twitter.updateStatusWithMedia(latestStatus, possiblySensitive, file);
+ for (TwitterListener listener : listeners) {
+ try {
+ listener.updatedStatusWithMedia(status);
+ } catch (Exception ignore) {
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateStatusWithMedia(final StatusUpdate latestStatus,
+ final boolean possiblySensitive, final String mediaFilename, final InputStream mediaBody) {
+ getDispatcher().invokeLater(new AsyncTask(UPDATE_STATUS_WITH_MEDIA, listeners) {
+ @Override
+ void invoke(List<TwitterListener> listeners) throws TwitterException {
+ Status status = twitter.updateStatusWithMedia(latestStatus, possiblySensitive, mediaFilename, mediaBody);
+ for (TwitterListener listener : listeners) {
+ try {
+ listener.updatedStatusWithMedia(status);
+ } catch (Exception ignore) {
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void destroyStatus(final long statusId) {
getDispatcher().invokeLater(new AsyncTask(DESTROY_STATUS, listeners) {
public void invoke(List<TwitterListener> listeners) throws TwitterException {
@@ -2220,7 +2296,7 @@ public void invoke(List<TwitterListener> listeners) throws TwitterException {
}
});
}
-
+
/**
* {@inheritDoc}
*/
@@ -2237,7 +2313,7 @@ public void invoke(List<TwitterListener> listeners) throws TwitterException {
}
});
}
-
+
/**
* {@inheritDoc}
*/
@@ -115,6 +115,12 @@ public void gotShowStatus(Status statuses) {
public void updatedStatus(Status statuses) {
}
+ /**
+ * @since Twitter4J 2.2.5
+ */
+ public void updatedStatusWithMedia(Status status) {
+ }
+
public void destroyedStatus(Status destroyedStatus) {
}
@@ -96,6 +96,11 @@
void updatedStatus(Status status);
+ /**
+ * @since Twitter4J 2.2.5
+ */
+ void updatedStatusWithMedia(Status status);
+
void destroyedStatus(Status destroyedStatus);
/**
@@ -100,6 +100,7 @@ private Object readResolve() throws ObjectStreamException {
/*Status Methods*/
public static final TwitterMethod SHOW_STATUS = new TwitterMethod("SHOW_STATUS");
public static final TwitterMethod UPDATE_STATUS = new TwitterMethod("UPDATE_STATUS");
+ public static final TwitterMethod UPDATE_STATUS_WITH_MEDIA = new TwitterMethod("UPDATE_STATUS_WITH_MEDIA");
public static final TwitterMethod DESTROY_STATUS = new TwitterMethod("DESTROY_STATUS");
public static final TwitterMethod RETWEET_STATUS = new TwitterMethod("RETWEET_STATUS");
public static final TwitterMethod RETWEETS = new TwitterMethod("RETWEETS");
@@ -17,9 +17,6 @@
package twitter4j.api;
import twitter4j.Paging;
-import twitter4j.ResponseList;
-import twitter4j.Status;
-import twitter4j.TwitterException;
/**
* @author Joern Huxhorn - jhuxhorn at googlemail.com
@@ -64,7 +61,7 @@
* @since Twitter4J 2.0.1
*/
void getFavorites(String id, int page);
-
+
/**
* Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
* <br>This method calls http://api.twitter.com/1/favorites.json
@@ -74,7 +71,7 @@
* @since Twitter4J 2.2.5
*/
void getFavorites(Paging paging);
-
+
/**
* Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
* <br>This method calls http://api.twitter.com/1/favorites/[id].json
@@ -16,6 +16,9 @@
package twitter4j.api;
+import java.io.File;
+import java.io.InputStream;
+
import twitter4j.Paging;
import twitter4j.StatusUpdate;
@@ -128,4 +131,55 @@
* @since Twitter4J 2.2.3
*/
void getRetweetedByIDs(long statusId, Paging paging);
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param status the text of your status update
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param file the file of the media uploaded
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update_with_media">POST statuses/update_with_media | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ void updateStatusWithMedia(String statusText, boolean possiblySensitive, File file);
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param status the text of your status update
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param mediaFilename the filename of the media uploaded
+ * @param mediaBody the body of the media uploaded
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update_with_media">POST statuses/update_with_media | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ void updateStatusWithMedia(String statusText, boolean possiblySensitive, String mediaFilename, InputStream mediaBody);
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param latestStatus the latest status to be updated.
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param file the file of the media uploaded
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update">POST statuses/update | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ void updateStatusWithMedia(StatusUpdate latestStatus, boolean possiblySensitive, File file);
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param latestStatus the latest status to be updated.
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param mediaFilename the filename of the media uploaded
+ * @param mediaBody the body of the media uploaded
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update">POST statuses/update | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ void updateStatusWithMedia(StatusUpdate latestStatus, boolean possiblySensitive, String mediaFilename, InputStream mediaBody);
+
}
@@ -504,6 +504,11 @@ public void updatedStatus(Status status) {
notifyResponse();
}
+ public void updatedStatusWithMedia(Status status) {
+ this.status = status;
+ notifyResponse();
+ }
+
public void destroyedStatus(Status destroyedStatus) {
this.status = destroyedStatus;
notifyResponse();
@@ -449,6 +449,62 @@ public Status updateStatus(StatusUpdate latestStatus) throws TwitterException {
/**
* {@inheritDoc}
*/
+ public Status updateStatusWithMedia(String status,
+ boolean possiblySensitive, File file) throws TwitterException {
+ ensureAuthorizationEnabled();
+ return factory.createStatus(post(conf.getUploadBaseURL()
+ + "statuses/update_with_media.json",
+ new HttpParameter[]{ new HttpParameter("status", status)
+ , new HttpParameter("possibly_sensitive", possiblySensitive)
+ , new HttpParameter("media[]", file)}));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Status updateStatusWithMedia(String status, boolean possiblySensitive,
+ String mediaFilename, InputStream mediaBody) throws TwitterException {
+ ensureAuthorizationEnabled();
+ return factory.createStatus(post(conf.getUploadBaseURL()
+ + "statuses/update_with_media.json",
+ new HttpParameter[]{ new HttpParameter("status", status)
+ , new HttpParameter("possibly_sensitive", possiblySensitive)
+ , new HttpParameter("media[]", mediaFilename, mediaBody)}));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Status updateStatusWithMedia(StatusUpdate latestStatus,
+ boolean possiblySensitive, File file) throws TwitterException {
+ ensureAuthorizationEnabled();
+ HttpParameter[] params = new HttpParameter[]{
+ new HttpParameter("possibly_sensitive", possiblySensitive),
+ new HttpParameter("media[]", file),
+ };
+ return factory.createStatus(post(conf.getUploadBaseURL()
+ + "statuses/update_with_media.json",
+ mergeParameters(latestStatus.asHttpParameterArray(), params)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Status updateStatusWithMedia(StatusUpdate latestStatus, boolean possiblySensitive,
+ String mediaFilename, InputStream mediaBody) throws TwitterException {
+ ensureAuthorizationEnabled();
+ HttpParameter[] params = new HttpParameter[]{
+ new HttpParameter("possibly_sensitive", possiblySensitive),
+ new HttpParameter("media[]", mediaFilename, mediaBody),
+ };
+ return factory.createStatus(post(conf.getUploadBaseURL()
+ + "statuses/update_with_media.json",
+ mergeParameters(latestStatus.asHttpParameterArray(), params)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Status destroyStatus(long statusId) throws TwitterException {
ensureAuthorizationEnabled();
return factory.createStatus(post(conf.getRestBaseURL()
@@ -16,9 +16,6 @@
package twitter4j;
-
-import twitter4j.internal.http.HttpResponse;
-
/**
* Super interface of Twitter Response data interfaces which indicates that rate limit status is avaialble.
*
@@ -16,6 +16,9 @@
package twitter4j.api;
+import java.io.File;
+import java.io.InputStream;
+
import twitter4j.IDs;
import twitter4j.Paging;
import twitter4j.ResponseList;
@@ -152,4 +155,62 @@
* @since Twitter4J 2.2.3
*/
IDs getRetweetedByIDs(long statusId, Paging paging) throws TwitterException;
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param status the text of your status update
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param file the file of the media uploaded
+ * @return the latest status
+ * @throws TwitterException when Twitter service or network is unavailable
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update_with_media">POST statuses/update_with_media | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ Status updateStatusWithMedia(String status, boolean possiblySensitive, File file) throws TwitterException;
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param status the text of your status update
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param mediaFilename the filename of the media uploaded
+ * @param mediaBody the body of the media uploaded
+ * @return the latest status
+ * @throws TwitterException when Twitter service or network is unavailable
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update_with_media">POST statuses/update_with_media | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ Status updateStatusWithMedia(String status, boolean possiblySensitive, String mediaFilename, InputStream mediaBody) throws TwitterException;
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param latestStatus the latest status to be updated.
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param file the file of the media uploaded
+ * @return the latest status
+ * @throws TwitterException when Twitter service or network is unavailable
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update">POST statuses/update | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ Status updateStatusWithMedia(StatusUpdate latestStatus, boolean possiblySensitive, File file) throws TwitterException;
+
+ /**
+ * Updates the authenticating user's status and attaches media for upload. The Tweet text will be rewritten to include the media URL(s), which will reduce the number of characters allowed in the Tweet text. If the URL(s) cannot be appended without text truncation, the tweet will be rejected and this method will return an HTTP 403 error.
+ * <br>This method calls http://upload.twitter.com/1/statuses/update_with_media
+ *
+ * @param latestStatus the latest status to be updated.
+ * @param possiblySensitive Set to true for content which may not be suitable for every audience
+ * @param mediaFilename the filename of the media uploaded
+ * @param mediaBody the body of the media uploaded
+ * @return the latest status
+ * @throws TwitterException when Twitter service or network is unavailable
+ * @see <a href="https://dev.twitter.com/docs/api/1/post/statuses/update">POST statuses/update | Twitter Developers</a>
+ * @since Twitter4J 2.2.5
+ */
+ Status updateStatusWithMedia(StatusUpdate latestStatus, boolean possiblySensitive, String mediaFilename, InputStream mediaBody) throws TwitterException;
}
@@ -102,6 +102,8 @@
String getSiteStreamBaseURL();
+ String getUploadBaseURL();
+
boolean isIncludeRTsEnabled();
boolean isIncludeEntitiesEnabled();
Oops, something went wrong. Retry.

0 comments on commit 665ae1d

Please sign in to comment.