public string TinyUrl(string Url)
{ try
{
if (Url.Length <= 30)
{
return Url;
}
if (!Url.ToLower().StartsWith("http") && !Url.ToLower().StartsWith("ftp"))
{
Url = "http://" + Url;
}
var request = WebRequest.Create("http://tinyurl.com/api-create.php?url=" + Url);
var res = request.GetResponse();
string text;
using (var reader = new StreamReader(res.GetResponseStream()))
{
text = reader.ReadToEnd();
}
return text;
}
catch (Exception)
{
return Url;
}
}
You can use this function to create tiny url