Tweet Length

May 13, 2014 at 9:44 PM
I get the following error from Twitter: Status is over 140 characters

This happens to two different tweets, but both are exactly 140 chars. They do both contain links in case that is a factor.

I get this error when I post with: Tweetinvi.Tweet.PublishTweet(text).

I've been trying to figure this out on my own, but I'm a bit stuck. When I do the following:
var t = Tweetinvi.Tweet.CreateTweet(text);
t.Length = 43, even though the "text" parameter passed in is 140 characters.

If someone could point me in the right direction I'd appreciate it.
May 13, 2014 at 10:06 PM
Edited May 13, 2014 at 10:06 PM

Could you please share the exact text you are sending to Twitter.
I need it to be exactly the same because every character is important.

Tweet.Length should in theory give you the size of the text as decided by Twitter.

And yes, links are a factor. The length calculator of a tweet is quite complicated.

May 13, 2014 at 10:07 PM
Exact Text:

"Webinar: How linear guide wheels can be used in any environment from clean room to extra dirty, oven to freezer @BWCnews"
May 13, 2014 at 10:16 PM
The length I receive is 143 not 43, this is the same as on the Twitter website.
The reason is that you have a link. A link is considered by Twitter as 22 or 23 characters based on whether it is an http or https website.

You can use RemainingCharacters to know how many characters you have left in your text.
May 19, 2014 at 5:40 PM
Exact Text:
"NOW-FREE/4 Parties! Live Shows/Music/Art Walk Weekend. MAP, & interactive for every Smart/iphone:"

The Tweet.TweetRemainingCharacters() returns back "2", and if I try to paste this directly into twitter it shows me a -7.

I wrote a little method to handle the case where your "TweetRemainingCharacters()" returns back a negative number...but this one has me stumped.

Is there something I should be looking for before posting to twitter as far as the length goes? Is there a way to handle these issues?
May 19, 2014 at 9:23 PM

There sure are some cases that won't work with the algorithm and I will be happy to fix them if you find any.
I will have a look into this one.

Aug 4, 2014 at 9:00 AM
Edited Aug 4, 2014 at 9:00 AM
Hey Linvi,

I'm tweeting a file and a link. The length does not seem to be taken the file into account:
File f = new File(@"C:\Users\k.bakker\Desktop\Stuff\Media\Photos\Potloodjes.jpg", null);

var twt = Tweet.CreateTweet("Hulp nodig op vakantie? Dan is het handig dat je bij onverwachte gebeurtenissen een beroep kunt doen op service.");

int remaining = twt.TweetRemainingCharacters();
The anwer I get is 5. This should be -18:


Any ideas what I could do to get the right amount?