Embed short urls (tinyurls) for twitter in C #?

how do you convert full (long) urls to short urls (like tinyurls) in c # for twitter? I guess this is probably very simple with the right api. Does anyone know of a good api for this?

+4
source share
3 answers

I just published an article about this with bit.ly in a C # application.

Note that the .ly bit requires a free login key, which you will need for the code to work.

+2
source

You just need to make a request http://tinyurl.com/api-create.php?url={url} , replacing {url} with the desired URL and read the contents of the page.

Here is an example:

 public string ShortUrl(string url) { WebRequest request = WebRequest.Create(string.Format("http://tinyurl.com/api-create.php?url={0}", url)); Stream stream = request.GetResponse().GetResponseStream(); StreamReader reader = new StreamReader(stream); return reader.ReadLine(); } 
+5
source
0
source

Source: https://habr.com/ru/post/1342212/


All Articles