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

Advertisements

Leave a message please

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s