Videos in Direct Messages


#1

Just seen some news articles that videos are now supported in Dms

I have two questions.

1 is read support already in place for this like images are?
2 is there any plans for sending images and videos in dms as part of the API?


#2

Hey @richardhyland - these are great questions. I’m not 100% up to date on these changes from an API perspective as my attention has been elsewhere. Please give us a little while to check on what is going on with regard to these questions. My initial instinct is “no API support immediately in the same way that images are not yet supported”, but we should clarify this for you all!


#3

Getting videos in DM’s

Videos are already included in Direct Messages entities as you can see in the example below. I am able to access those even without needing to provide OAuth headers, not sure why.

{
    "id" : 700621577105317891,
    "id_str" : "700621577105317891",
    "created_at" : "Fri Feb 19 10:02:55 +0000 2016",
    "sender_screen_name" : "ePirat",
    /* … */
    "sender_id_str" : "42290913",
    "text" : " https:\/\/t.co\/ALfn70d5FO",
    "recipient" : {
      /* … */
    },
    "entities" : {
      "media" : [
        {
          "id_str" : "700621382330126338",
          "media_url_https" : "https:\/\/pbs.twimg.com\/dm_video_preview\/700621382330126338\/img\/oQSrt2k9hiQADMw6eq4MX5Qd6FYlxOvX2QxTzNDLy00.jpg",
          "expanded_url" : "https:\/\/twitter.com\/messages\/media\/700621577105317891",
          "id" : 700621382330126338,
          "sizes" : {
            "large" : {
              "w" : 1024,
              "h" : 576,
              "resize" : "fit"
            },
            "medium" : {
              "w" : 600,
              "h" : 338,
              "resize" : "fit"
            },
            "thumb" : {
              "w" : 150,
              "h" : 150,
              "resize" : "crop"
            },
            "small" : {
              "w" : 340,
              "h" : 191,
              "resize" : "fit"
            }
          },
          "display_url" : "pic.twitter.com\/ALfn70d5FO",
          "video_info" : {
            "aspect_ratio" : [
              16,
              9
            ],
            "duration_millis" : 4068,
            "variants" : [
              {
                "bitrate" : 2176000,
                "content_type" : "video\/mp4",
                "url" : "https:\/\/video.twimg.com\/dm_video\/700621382330126338\/vid\/1280x720\/fjGgNK29EXxfp_FubhV1EyYD7LEoNjmP9KOQJLfvjJ8.mp4"
              },
              {
                "bitrate" : 320000,
                "content_type" : "video\/mp4",
                "url" : "https:\/\/video.twimg.com\/dm_video\/700621382330126338\/vid\/320x180\/MGDfjxKSNO845tiu15qQZA1eKM2PxIo_V-e9FTB8B98.mp4"
              },
              {
                "url" : "https:\/\/video.twimg.com\/dm_video\/700621382330126338\/pl\/GTPbYQI9Sf8VACW_kAQQs2kkFNGblo10aSX1mmPfacM.m3u8",
                "content_type" : "application\/x-mpegURL"
              },
              {
                "url" : "https:\/\/video.twimg.com\/dm_video\/700621382330126338\/pl\/GTPbYQI9Sf8VACW_kAQQs2kkFNGblo10aSX1mmPfacM.mpd",
                "content_type" : "application\/dash+xml"
              },
              {
                "bitrate" : 832000,
                "content_type" : "video\/mp4",
                "url" : "https:\/\/video.twimg.com\/dm_video\/700621382330126338\/vid\/640x360\/Kf5UduKLmmS3cRTefQjogn9d1Ma4O--8IPY6lU0B4I4.mp4"
              }
            ]
          },
          "type" : "video",
          "indices" : [
            1,
            24
          ],
          "media_url" : "https:\/\/pbs.twimg.com\/dm_video_preview\/700621382330126338\/img\/oQSrt2k9hiQADMw6eq4MX5Qd6FYlxOvX2QxTzNDLy00.jpg",
          "url" : "https:\/\/t.co\/ALfn70d5FO"
        }
      ],
      "symbols" : [

      ],
      "user_mentions" : [

      ],
      "urls" : [
        {
          "display_url" : "pic.twitter.com\/ALfn70d5FO",
          "url" : "https:\/\/t.co\/ALfn70d5FO",
          "indices" : [
            1,
            24
          ],
          "expanded_url" : "https:\/\/twitter.com\/messages\/media\/700621577105317891"
        }
      ],
      "hashtags" : [

      ]
    },
    "sender" : {
      /* … */
    },
    "sender_id" : 42290913
}

Sending videos in DMs

Sending videos in DMs is, like sending images, as far as I know not yet possible for third party clients.
(Getting “Not authorized to use this endpoint.”)


#4

Useful discussion. With the recent dm ad earlier today, https://twitter.com/twitter/status/702546169109479424 reminded me to check the forums.

It would be excellent to see more in the API for direct messages. And video in DMs would be marvelous!


#5

helo can you show me how to send image via dm with twitter4j ?
thank you


#6

You can’t at the present time via the API