Using the api of TinyUrl is really simple, here's how:
string uriToCompress = "http://blog.esponjasoft.com/2008/08/28/RealSimpleBackup.aspx";
string tinyUrlAPIFormat = "http://tinyurl.com/api-create.php?url={0}";
string requestUri = string.Format(tinyUrlAPIFormat, uriToCompress);
HttpWebRequest request = WebRequest.Create(requestUri) as HttpWebRequest;
HttpWebResponse response = null;
Uri responseUri = null;
try
{
response = request.GetResponse() as HttpWebResponse;
StreamReader sr = new StreamReader(response.GetResponseStream());
responseUri = new Uri(sr.ReadToEnd());
}
catch (Exception ex)
{
//handle exception
}
Console.WriteLine("Compressed uri: {0}", responseUri);
- Ramiro Berrelleza