Tweet that seems to have an attached image but no entity into JSON data from rest api

extended-tweet

#1

Hello,
there is this tweet:


that displayed into twitter website seems to have an attached image.

But when I retrieve data from the REST API about this tweet I get the following JSON that instead of containing media/images entity entry for that image, it has an urls entity instead. And then, our code fails to recognise it has having an image attached because, our code doesn’t parse urls but it’s looking for media/images entries.

Why this is happening ?

=== JSON of tweet returned from REST API ===

    {
    	"created_at": "Tue Feb 14 09:49:05 +0000 2017",
    	"id": 831440116371578880,
    	"id_str": "831440116371578880",
    	"text": "@greateranglia #ShareTheGAlove shout out to this lovely couple who just got married and kindly donated to our chose\\u2026 https:\\/\\/t.co\\/4EecCsOSgf",
    	"truncated": true,
    	"entities": {
    		"hashtags": [{
    			"text": "ShareTheGAlove",
    			"indices": [15, 30]
    		}],
    		"symbols": [],
    		"user_mentions": [{
    			"screen_name": "greateranglia",
    			"name": "Greater Anglia",
    			"id": 157996395,
    			"id_str": "157996395",
    			"indices": [0, 14]
    		}],
    		"urls": [{
    			"url": "https:\\/\\/t.co\\/4EecCsOSgf",
    			"expanded_url": "https:\\/\\/twitter.com\\/i\\/web\\/status\\/831440116371578880",
    			"display_url": "twitter.com\\/i\\/web\\/status\\/8\\u2026",
    			"indices": [117, 140]
    		}]
    	},
    	"source": "<a href=\\"
    	http: \\ /\\/twitter.com\\ / download\\ / iphone\\ " rel=\\"
    	nofollow\\ ">Twitter for iPhone<\\/a>",
    	"in_reply_to_status_id": null,
    	"in_reply_to_status_id_str": null,
    	"in_reply_to_user_id": 157996395,
    	"in_reply_to_user_id_str": "157996395",
    	"in_reply_to_screen_name": "greateranglia",
    	"user": {
    		"id": 20615856,
    		"id_str": "20615856",
    		"name": "Nicola",
    		"screen_name": "faireunepipi",
    		"location": "Norwich",
    		"description": "",
    		"url": null,
    		"entities": {
    			"description": {
    				"urls": []
    			}
    		},
    		"protected": false,
    		"followers_count": 42,
    		"friends_count": 174,
    		"listed_count": 0,
    		"created_at": "Wed Feb 11 19:18:05 +0000 2009",
    		"favourites_count": 182,
    		"utc_offset": null,
    		"time_zone": null,
    		"geo_enabled": true,
    		"verified": false,
    		"statuses_count": 177,
    		"lang": "en",
    		"contributors_enabled": false,
    		"is_translator": false,
    		"is_translation_enabled": false,
    		"profile_background_color": "352726",
    		"profile_background_image_url": "http:\\/\\/abs.twimg.com\\/images\\/themes\\/theme5\\/bg.gif",
    		"profile_background_image_url_https": "https:\\/\\/abs.twimg.com\\/images\\/themes\\/theme5\\/bg.gif",
    		"profile_background_tile": false,
    		"profile_image_url": "http:\\/\\/pbs.twimg.com\\/profile_images\\/1134654672\\/ca02a16d-a6f3-44c6-a077-af86205130bf_normal.png",
    		"profile_image_url_https": "https:\\/\\/pbs.twimg.com\\/profile_images\\/1134654672\\/ca02a16d-a6f3-44c6-a077-af86205130bf_normal.png",
    		"profile_link_color": "D02B55",
    		"profile_sidebar_border_color": "829D5E",
    		"profile_sidebar_fill_color": "99CC33",
    		"profile_text_color": "3E4415",
    		"profile_use_background_image": true,
    		"has_extended_profile": false,
    		"default_profile": false,
    		"default_profile_image": false,
    		"following": null,
    		"follow_request_sent": null,
    		"notifications": null,
    		"translator_type": "none"
    	},
    	"geo": null,
    	"coordinates": null,
    	"place": null,
    	"contributors": null,
    	"is_quote_status": false,
    	"retweet_count": 1,
    	"favorite_count": 1,
    	"favorited": false,
    	"retweeted": false,
    	"possibly_sensitive": false,
    	"possibly_sensitive_appealable": false,
    	"lang": "en"
    }

#2

Use the tweet_mode=extended parameter to retrieve the full Tweet (the truncated field shows that this is an extended Tweet).


#3

What is an extended tweet ?
Could you point me to some documentation ?


#4

https://dev.twitter.com/overview/api/upcoming-changes-to-tweets


#5

Thank you very much.

Do you know how to activate extended mode into GNIP powertrack ?


#6

GNIP should stream both formats I believe.

There is an additional support document covering this.


#7

Thank you, very handful :slight_smile:


#8

Last question … I promise :slight_smile:

Is there an upper bound on the length of full_text ? or in other words, is there a limit on the length of an extended tweet text ?


#9

On the Upcoming changes page I linked first, under “Limits”

  • overall Tweet text: limited to 3,000 Unicode code-points, after applying Unicode Normalization Form C.

At the current time the prefix changes have not yet been rolled out, so this should never be reached - and the Tweet text itself remains 140 characters so this only brings in additional space for mentions and URLs. Additionally, note the statement “Developers must avoid hard-coding length assumptions into their applications” in that page.