twitter4j.api

## Interface DirectMessagesResources

All Known Subinterfaces:
  Twitter

    public interface DirectMessagesResources

Author:
  Joern Huxhorn - jhuxhorn at googlemail.com

### Method Summary

All Methods Instance Methods Abstract Methods Deprecated Methods
`DirectMessage` `destroyDirectMessage(long id)` Deletes the direct message specified in the required ID parameter.
`ResponseList<DirectMessage>` `getDirectMessages()` Deprecated. use `getDirectMessages(int)` instead
`DirectMessageList` `getDirectMessages(int count)` Returns all Direct Message events (both sent and received) within the last 30 days.
`DirectMessageList` `getDirectMessages(int count, String cursor)` Returns all Direct Message events (both sent and received) within the last 30 days.
`ResponseList<DirectMessage>` `getDirectMessages(Paging paging)` Deprecated. use `getDirectMessages(int)` instead
`InputStream` `getDMImageAsStream(String url)` Returns a stream of the image included in direct messages.
`ResponseList<DirectMessage>` `getSentDirectMessages()` Deprecated. use `getDirectMessages(int)` instead
`ResponseList<DirectMessage>` `getSentDirectMessages(Paging paging)` Deprecated. use `getDirectMessages(int)` instead
`DirectMessage` `sendDirectMessage(long userId, String text)` Sends a new direct message to the specified user from the authenticating user.
`DirectMessage` `sendDirectMessage(long userId, String text, long mediaId)` Sends a new direct message to the specified user from the authenticating user.
`DirectMessage` `sendDirectMessage(String screenName, String text)` Sends a new direct message to the specified user from the authenticating user.
`DirectMessage` `showDirectMessage(long id)` Returns a single Direct Message event by the given id.

### Method Detail

#### getDirectMessages

    ResponseList<DirectMessage> getDirectMessages()
                                           throws TwitterException

Deprecated. use `getDirectMessages(int)` instead
Returns a list of the direct messages sent to the authenticating user.
This method calls https://api.twitter.com/1.1/direct_messages

Returns:
  List
Throws:
  `TwitterException` - when Twitter service or network is unavailable
See Also:
  GET direct_messages | Twitter Developers

#### getDirectMessages

    ResponseList<DirectMessage> getDirectMessages(Paging paging)
                                           throws TwitterException

Deprecated. use `getDirectMessages(int)` instead
Returns a list of the direct messages sent to the authenticating user.
This method calls https://api.twitter.com/1.1/direct_messages

Parameters:
  `paging` - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
  List
Throws:
  `TwitterException` - when Twitter service or network is unavailable
See Also:
  GET direct_messages | Twitter Developers

#### getSentDirectMessages

    ResponseList<DirectMessage> getSentDirectMessages()
                                               throws TwitterException

Deprecated. use `getDirectMessages(int)` instead
Returns a list of the direct messages sent by the authenticating user.
This method calls https://api.twitter.com/1.1/direct_messages/sent

Returns:
  List
Throws:
  `TwitterException` - when Twitter service or network is unavailable
See Also:
  GET direct_messages/sent | Twitter Developers

#### getSentDirectMessages

    ResponseList<DirectMessage> getSentDirectMessages(Paging paging)
                                               throws TwitterException

Deprecated. use `getDirectMessages(int)` instead
Returns a list of the direct messages sent by the authenticating user.
This method calls https://api.twitter.com/1.1/direct_messages/sent

Parameters:
  `paging` - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
  List
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4J 2.0.1
See Also:
  GET direct_messages/sent | Twitter Developers

#### getDirectMessages

    DirectMessageList getDirectMessages(int count)
                                 throws TwitterException

Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order.
This method calls https://api.twitter.com/1.1/direct_messages/events/list.json

Parameters:
  `count` - Max number of events to be returned. 20 default. 50 max.
Returns:
  List
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4J 4.0.7
See Also:
  GET direct_messages/events/list — Twitter Developers

#### getDirectMessages

    DirectMessageList getDirectMessages(int count,
                                        String cursor)
                                 throws TwitterException

Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order.
This method calls https://api.twitter.com/1.1/direct_messages/events/list.json

Parameters:
  `count` - Max number of events to be returned. 20 default. 50 max.
  `cursor` - For paging through result sets greater than 1 page, use the “next_cursor” property from the previous request.
Returns:
  List
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4J 4.0.7
See Also:
  GET direct_messages/events/list — Twitter Developers

#### showDirectMessage

    DirectMessage showDirectMessage(long id)
                             throws TwitterException

Returns a single Direct Message event by the given id.
This method has not been finalized and the interface is subject to change in incompatible ways.
This method calls https://api.twitter.com/1.1/direct_messages/events/show.json

Parameters:
  `id` - message id
Returns:
  DirectMessage
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4J 2.1.9
See Also:
  #newtwitter and the API - Twitter API Announcements | Google Group

#### destroyDirectMessage

    DirectMessage destroyDirectMessage(long id)
                                throws TwitterException

Deletes the direct message specified in the required ID parameter.
This method calls https://api.twitter.com/1.1/direct_messages/events/destroy.json

Parameters:
  `id` - The id of the Direct Message event that should be deleted.
Returns:
  a dummy DirectMessage object. Starting from Twitter4J 4.0.7, all getters will throw IllegalStateException due to the API limitation. The return value will be changed to void in the furure release.
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4J 2.0.1
See Also:
  DELETE direct_messages/events/destroy — Twitter Developers

#### sendDirectMessage

    DirectMessage sendDirectMessage(long userId,
                                    String text)
                             throws TwitterException

Sends a new direct message to the specified user from the authenticating user. Requires both the user and text parameters below. The text will be trimmed if the length of the text is exceeding 140 characters.
This method calls https://dev.twitter.com/rest/reference/post/direct_messages/events/new

Parameters:
  `userId` - the user id of the user to whom send the direct message
  `text` - The text of your direct message.
Returns:
  DirectMessage
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4j 2.1.0
See Also:
  POST direct_messages/events/new (message_create) — Twitter Developers

#### sendDirectMessage

    DirectMessage sendDirectMessage(long userId,
                                    String text,
                                    long mediaId)
                             throws TwitterException

Sends a new direct message to the specified user from the authenticating user. Requires both the user and text parameters below. The text will be trimmed if the length of the text is exceeding 140 characters.
This method calls https://dev.twitter.com/rest/reference/post/direct_messages/events/new

Parameters:
  `userId` - the user id of the user to whom send the direct message
  `text` - The text of your direct message.
  `mediaId` - id of media attachment
Returns:
  DirectMessage
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4J 4.0.7
See Also:
  POST direct_messages/events/new (message_create) — Twitter Developers

#### sendDirectMessage

    DirectMessage sendDirectMessage(String screenName,
                                    String text)
                             throws TwitterException

Sends a new direct message to the specified user from the authenticating user. Requires both the user and text parameters below. The text will be trimmed if the length of the text is exceeding 140 characters.
This method calls https://api.twitter.com/1.1/direct_messages/new

Parameters:
  `screenName` - the screen name of the user to whom send the direct message
  `text` - The text of your direct message.
Returns:
  DirectMessage
Throws:
  `TwitterException` - when Twitter service or network is unavailable
See Also:
  POST direct_messages/events/new (message_create) — Twitter Developers

#### getDMImageAsStream

    InputStream getDMImageAsStream(String url)
                            throws TwitterException

Returns a stream of the image included in direct messages.

Parameters:
  `url` - image url
Returns:
  InputStream
Throws:
  `TwitterException` - when Twitter service or network is unavailable
Since:
  Twitter4J 3.0.6
See Also:
  Access media shared in direct messages | Twitter Developers