Update API counting msg length incorrectly

media
api

#1

Two related problems:

  1. The API “update.json” method is counting the “status” length incorrectly. It is saying our message length is over 140 characters. Our entire message is:

New art “The Escape We Never Wanted To End” added to gallery! View it, frame it, buy it, at: http://www.sample.com/drame?i=1-2 @sample

That is 134 characters. Perhaps the incorrect length calculation is related to also including the “media_ids” param, as someone else complained about that issue: Statuses/update_with_media.json & statuses/update.json occours Status is over 140 characters."

  1. Twitter just suspended our app without warning or explanation, but probably due to 5 of these false “Status is over 140 characters” errors. Unacceptable Twitter! This app is live and your auto suspension is now causing errors. Restore the app immediately. And don’t automatically suspend a live app without some sort of warning!

Statuses/update_with_media.json & statuses/update.json occours Status is over 140 characters."
#2

The web-based Tweet form is showing the same bug. It’s caused when uploading an image with the Tweet.

Twitter is counting the image as 24 characters of the character count. So when uploading an image, you now have 24 less characters available for your message.

Is this how it’s supposed to work? Or is this a bug?

When uploading media with a tweet through the API, are the status messages now limited to only 116 characters instead of 140 characters?


#3

Yes, after some research, including images with a tweet reduces the character count by 24. That is by design, even though no documentation includes that very important bit of information. Hey Twitter: Improve your documentation!

As shown in this post: Tweet length ok in Twitter User Interface but too long through API
…you can check how many characters are removed when including an image. Notice that it’s already increased by 1, from 23 to 24 characters, since that post. Query the following method to find the current character count that media removes: https://dev.twitter.com/rest/reference/get/help/configuration

Now to get Twitter to un-suspend our app… And hopefully improve their documentation so other app developers don’t get fubar’ed.


#4

This has always been the case. It’s mentioned on the old update_with_media documentation https://dev.twitter.com/rest/reference/post/statuses/update_with_media


#5

It needs to be in the current documentation, and also made much clearer than a brief mention in one sentence. The repercussions of not knowing that info are disastrous, as we discovered.

On that note, Twitter needs to NOT automatically disable a live app due to 5 tweets that were over the 140-character length. 8 hours later, still no response from Twitter, and the app is still offline.


#6

16 hours since Twitter auto-disabled our live app. The app is still offline and still no response from Twitter to our support ticket (23199659).


#7

It’s a requirement of the Twitter product so it’s documented on Posting photos on Twitter

Your Tweet’s character count will update to include the pic.twitter.com URL for your photo(s).


#8

The documentation for the update method needs to mention in the media_ids section that:

Note: The max length of your status message will be reduced by 24 characters when including media. Be careful to account for this, else you’ll receive error code 186 ‘Status over 140 characters’. The media character count can change. Call the ‘/help/configuration’ method to get the current ‘characters_reserved_per_media’ value.

Something along those lines needs to be in the appropriate sections of the documentation. Right now there is no mention whatsoever in the API documentation, and just a vague one sentence mention in the old documentation.


#9

Just an FYI: URLs posted in a tweet now always take up 23 characters. It used to be the case that an http URL consumed 22 chars and an https URL consumed 23 chars. Now Twitter has changed it so that all URLs posted in a tweet consume 23 chars regardless. This was a rude awakening when my application failed to send out some tweets that had been scheduled to go out for some of our users due to being a single character over the limit.

I have written a complete .NET wrapper for the Twitter API over the last year and a half and can attest to the fact that Twitter’s documentation and support are about as good/accurate as your local cable company. Twitter’s error codes are some of the worst offenders. On occasion I’ve received error codes from an API call I’d made a thousand times that were just plain wrong and irrelevant to the call I was making.


#10

Yes, URLs (both http and https) are currently 23 characters. Attaching media (aka photos or video) is currently 24 characters. Which leaves you with 93 characters remaining for the status message.

As you know, these character lengths can change over time. I’ve written my code to call the API ‘configuration’ method daily, to store the current lengths. And if my code ever receives a ‘code 186/message over 140 characters’, then I also immediately call the ‘configuration’ method to ensure the URL/Media character lengths didn’t just change.

API ‘configuration’ method that tells you the current URL & Media character lengths: https://dev.twitter.com/rest/reference/get/help/configuration