Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter is scared of my lengthy url - gotta shorten it! [c#]

I have a website where everytime one of our customers reviews a new product it gets tweeted onto the company twitter account automatically.

for the actual tweeting, i am using the twitter api's directly, without any wrapper classes and libraries. its all working fine, except, when the post gets too lengthy, it doesnt get tweeted because twitter has just 140 character limit (my baby nephew can handle more characters than that!)

So what is the best way to shorten the url like bit.ly or tinyurl? do they provide some api's .net users? or does twitter has some url shortening service?

I could have just done something about it, but what I really want is an expert opinion, what is the best thing to do in a case like this.

ps: there are several closely related questions in here, but nothing was close enough for my situation.

like image 565
iamserious Avatar asked Dec 12 '22 20:12

iamserious


1 Answers

The TinyURL service has an incredibly simple API for generating short links.

Just make an HTTP request putting the given website in the query strnig as such:

http://tinyurl.com/api-create.php?url=https://stackoverflow.com/

and the output is your shortened URL! The HTTP response is simply a text/plain document containing the strnig. In this case, http://tinyurl.com/5cttyz.

Example

like image 181
Noldorin Avatar answered Jan 05 '23 16:01

Noldorin