Shorten Long URLs

Search Search and do some more to find no easy way to shrink your links. Well here are some great link shortening methods.

1) You can do single URL one by one with Google by going to http://goo.gl/. This one is awesome as you know it is from a reliable place and they also give a load of stats on how your url is doing.

2) You can find an API to do it. I have found this one was very easy by heyageek, done in javascript/JQuery . http://hayageek.com/jquery-url-shortener/

3) If you wanta VB.NET way to do it then the code is below. You are simply doing a web request to tinyurl.com and getting the response. This can be simply translated to C#, Javascript or any language you prefer.

//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

(adsbygoogle = window.adsbygoogle || []).push({});

 

 Function ShortenLinks(ByVal LongLink As String) As String

Dim NewShortURL As String = ""

Try

Dim rt As String = ""
Dim wRequest As WebRequest = Nothing
Dim wResponse As WebResponse = Nothing
Dim SR As StreamReader = Nothing

wRequest = WebRequest.Create("http://tinyurl.com/api-create.php?url=" & LongLink)
wResponse = wRequest.GetResponse

SR = New StreamReader(wResponse.GetResponseStream)
rt = SR.ReadToEnd

NewShortURL = rt

Catch ex As Exception
Response.Write(ex.Message & " // " & ex.StackTrace)
NewShortURL = ""
End Try


Return NewShortURL

End Function

Published by Chris Pateman - PR Coder

A Digital Technical Lead, constantly learning and sharing the knowledge journey.

Leave a message please

This site uses Akismet to reduce spam. Learn how your comment data is processed.