Some DMs with Pictures are Missing Media Tag

media
directmessages
streaming

#1

I’m finding that for some DMs with attached pictures, the JSON that comes in is missing the required media tag within entities. This does not happen for all DMs and I am unable to find any patterns for when it occurs and when it does not.

I’ve attached two DMs that were sent within a few minutes of each other between the same people with the same image attached. The only difference is a slight variation in the text. However, one of them has the media tag whereas the other does not.

If I query the REST API for the Tweet with the missing tag, the media information is returned so it seems like it’s a steaming issue.

Has media tag

        "direct_message": {
            "created_at": "Tue Apr 25 14:51:49 +0000 2017",
            "entities": {
                "hashtags": [],
                "media": [
                    {
                        "display_url": "pic.twitter.com/tkYDHZctvH",
                        "expanded_url": "https://twitter.com/messages/media/856883451273850883",
                        "id": 856883444751540225,
                        "id_str": "856883444751540225",
                        "indices": [
                            14,
                            37
                        ],
                        "media_url": "https://ton.twitter.com/1.1/ton/data/dm/856883451273850883/856883444751540225/PxjXwqr3.jpg",
                        "media_url_https": "https://ton.twitter.com/1.1/ton/data/dm/856883451273850883/856883444751540225/PxjXwqr3.jpg",
                        "sizes": {
                            "large": {
                                "h": 534,
                                "resize": "fit",
                                "w": 1024
                            },
                            "medium": {
                                "h": 312,
                                "resize": "fit",
                                "w": 600
                            },
                            "small": {
                                "h": 177,
                                "resize": "fit",
                                "w": 340
                            },
                            "thumb": {
                                "h": 150,
                                "resize": "crop",
                                "w": 150
                            }
                        },
                        "type": "photo",
                        "url": "https://t.co/tkYDHZctvH"
                    }
                ],
                "symbols": [],
                "urls": [
                    {
                        "display_url": "pic.twitter.com/tkYDHZctvH",
                        "expanded_url": "https://twitter.com/messages/media/856883451273850883",
                        "indices": [
                            14,
                            37
                        ],
                        "url": "https://t.co/tkYDHZctvH"
                    }
                ],
                "user_mentions": []
            },
            "id": 856883451273850883,
            "id_str": "856883451273850883",
            "recipient": {
                "contributors_enabled": false,
                "created_at": "Wed Jul 17 15:53:57 +0000 2013",
                "default_profile": true,
                "default_profile_image": false,
                "description": null,
                "favourites_count": 6185,
                "follow_request_sent": false,
                "followers_count": 69,
                "following": false,
                "friends_count": 56,
                "geo_enabled": false,
                "id": 1601235684,
                "id_str": "1601235684",
                "is_translation_enabled": false,
                "is_translator": false,
                "lang": "en",
                "listed_count": 27,
                "location": null,
                "name": "Sharon Smith",
                "notifications": false,
                "profile_background_color": "C0DEED",
                "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
                "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
                "profile_background_tile": false,
                "profile_image_url": "http://pbs.twimg.com/profile_images/513003494505070592/5yO3PMct_normal.jpeg",
                "profile_image_url_https": "https://pbs.twimg.com/profile_images/513003494505070592/5yO3PMct_normal.jpeg",
                "profile_link_color": "1DA1F2",
                "profile_sidebar_border_color": "C0DEED",
                "profile_sidebar_fill_color": "DDEEF6",
                "profile_text_color": "333333",
                "profile_use_background_image": true,
                "protected": false,
                "screen_name": "sharon_smith_1",
                "statuses_count": 312912,
                "time_zone": "Central Time (US & Canada)",
                "translator_type": "none",
                "url": null,
                "utc_offset": -18000,
                "verified": false
            },
            "recipient_id": 1601235684,
            "recipient_id_str": "1601235684",
            "recipient_screen_name": "sharon_smith_1",
            "sender": {
                "contributors_enabled": false,
                "created_at": "Thu Nov 24 00:53:01 +0000 2016",
                "default_profile": true,
                "default_profile_image": false,
                "description": null,
                "favourites_count": 0,
                "follow_request_sent": false,
                "followers_count": 0,
                "following": false,
                "friends_count": 0,
                "geo_enabled": false,
                "id": 801589402283765760,
                "id_str": "801589402283765760",
                "is_translation_enabled": false,
                "is_translator": false,
                "lang": "en",
                "listed_count": 0,
                "location": null,
                "name": "Wei",
                "notifications": false,
                "profile_background_color": "F5F8FA",
                "profile_background_image_url": null,
                "profile_background_image_url_https": null,
                "profile_background_tile": false,
                "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
                "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
                "profile_link_color": "1DA1F2",
                "profile_sidebar_border_color": "C0DEED",
                "profile_sidebar_fill_color": "DDEEF6",
                "profile_text_color": "333333",
                "profile_use_background_image": true,
                "protected": false,
                "screen_name": "Wei_Sprout",
                "statuses_count": 0,
                "time_zone": "Central Time (US & Canada)",
                "translator_type": "none",
                "url": null,
                "utc_offset": -18000,
                "verified": false
            },
            "sender_id": 801589402283765760,
            "sender_id_str": "801589402283765760",
            "sender_screen_name": "Wei_Sprout",
            "text": "single orange https://t.co/tkYDHZctvH"
        }

Missing media tag

        "direct_message": {
            "created_at": "Tue Apr 25 14:55:10 +0000 2017",
            "entities": {
                "hashtags": [],
                "symbols": [],
                "urls": [
                    {
                        "display_url": "pic.twitter.com/s3nWUxb7ad",
                        "expanded_url": "https://twitter.com/messages/media/856884292600942595",
                        "indices": [
                            21,
                            44
                        ],
                        "url": "https://t.co/s3nWUxb7ad"
                    }
                ],
                "user_mentions": []
            },
            "id": 856884292600942595,
            "id_str": "856884292600942595",
            "recipient": {
                "contributors_enabled": false,
                "created_at": "Wed Jul 17 15:53:57 +0000 2013",
                "default_profile": true,
                "default_profile_image": false,
                "description": null,
                "favourites_count": 6185,
                "follow_request_sent": false,
                "followers_count": 69,
                "following": false,
                "friends_count": 56,
                "geo_enabled": false,
                "id": 1601235684,
                "id_str": "1601235684",
                "is_translation_enabled": false,
                "is_translator": false,
                "lang": "en",
                "listed_count": 27,
                "location": null,
                "name": "Sharon Smith",
                "notifications": false,
                "profile_background_color": "C0DEED",
                "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
                "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
                "profile_background_tile": false,
                "profile_image_url": "http://pbs.twimg.com/profile_images/513003494505070592/5yO3PMct_normal.jpeg",
                "profile_image_url_https": "https://pbs.twimg.com/profile_images/513003494505070592/5yO3PMct_normal.jpeg",
                "profile_link_color": "1DA1F2",
                "profile_sidebar_border_color": "C0DEED",
                "profile_sidebar_fill_color": "DDEEF6",
                "profile_text_color": "333333",
                "profile_use_background_image": true,
                "protected": false,
                "screen_name": "sharon_smith_1",
                "statuses_count": 312912,
                "time_zone": "Central Time (US & Canada)",
                "translator_type": "none",
                "url": null,
                "utc_offset": -18000,
                "verified": false
            },
            "recipient_id": 1601235684,
            "recipient_id_str": "1601235684",
            "recipient_screen_name": "sharon_smith_1",
            "sender": {
                "contributors_enabled": false,
                "created_at": "Thu Nov 24 00:53:01 +0000 2016",
                "default_profile": true,
                "default_profile_image": false,
                "description": null,
                "favourites_count": 0,
                "follow_request_sent": false,
                "followers_count": 0,
                "following": false,
                "friends_count": 0,
                "geo_enabled": false,
                "id": 801589402283765760,
                "id_str": "801589402283765760",
                "is_translation_enabled": false,
                "is_translator": false,
                "lang": "en",
                "listed_count": 0,
                "location": null,
                "name": "Wei",
                "notifications": false,
                "profile_background_color": "F5F8FA",
                "profile_background_image_url": null,
                "profile_background_image_url_https": null,
                "profile_background_tile": false,
                "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
                "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
                "profile_link_color": "1DA1F2",
                "profile_sidebar_border_color": "C0DEED",
                "profile_sidebar_fill_color": "DDEEF6",
                "profile_text_color": "333333",
                "profile_use_background_image": true,
                "protected": false,
                "screen_name": "Wei_Sprout",
                "statuses_count": 0,
                "time_zone": "Central Time (US & Canada)",
                "translator_type": "none",
                "url": null,
                "utc_offset": -18000,
                "verified": false
            },
            "sender_id": 801589402283765760,
            "sender_id_str": "801589402283765760",
            "sender_screen_name": "Wei_Sprout",
            "text": "more single oranges! https://t.co/s3nWUxb7ad"
        }

#3

Keep in mind that you’re mixing new and old APIs here. The media attachments are part of the new DM APIs, and if you use the new webhooks-based Account Activity API then I’d expect that you would see those as part of the DM bodies. I do not expect the streaming APIs to be updated to support this, as (per the roadmap) these will be going away in the longer term, with Account Activity API as the intended replacement.


#5

@andypiper Thanks for the information!

My confusion is that some of the DMs coming from the Streaming API currently have this media tag so it seems like there is already support for it.

Additionally, I was unable to find any documentation stating that the DM media tag is only part of the new Account Activity API. On the Entities in Objects page, it states that Entities for Direct Messages are very similar to entities for Tweets and Tweets support the media tag for both the REST and Streaming APIs. That page even gives an example of a DM with a media tag.


#6

We too faced this problem in streaming response. Some dm contains media tag and some dms its missing.


#7

I may have mis-spoken in my earlier response - we are looking into some other reports of this behaviour at the moment. Apologies for any confusion that I may have caused.


#8

Any update on this?


#9

No update at the moment, this is being investigated.


#10

We are also facing the same issue. Media tags are missing for some of the DMS.

Any update of this issue


#11

Any updates on this issue?