User-1764838006 posted
I come across these in my search of a URL Shrinker. This is not an advertisment scheme just wanting to do my part.
Import system.io
import system.net
AdFly pays you for shrinking urls
Dim Link As String = "$URL_to_shrink$"
Dim API_KEY As String = "$ADFLY_API_KEY$" 'change this with your api key.
Dim ID As String = "$ADFLY_ID$" 'change this with your id.
Dim wr As HttpWebRequest = WebRequest.Create("http://api.adf.ly/api.php?key=" & API_KEY & "&uid=" & ID & "&advert_type=int&domain=q.gs&url=" & Link)
Dim ws As HttpWebResponse = wr.GetResponse
Dim read As StreamReader = New StreamReader(ws.GetResponseStream)
Dim responeString As String = read.ReadToEnd
here is another for google url shrinking
Public Shared Function Shorten(url As String) As String
Dim key As String = "$MYGOOGLEAPIKEY$"
Dim post As String = "{""longUrl"": """ & url & """}"
Dim shortUrl As String = url
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" & key), HttpWebRequest)
Try
request.ServicePoint.Expect100Continue = False
request.Method = "POST"
request.ContentLength = post.Length
request.ContentType = "application/json"
request.Headers.Add("Cache-Control", "no-cache")
Using requestStream As Stream = request.GetRequestStream()
Dim postBuffer As Byte() = Encoding.ASCII.GetBytes(post)
requestStream.Write(postBuffer, 0, postBuffer.Length)
End Using
Using response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Using responseStream As Stream = response.GetResponseStream()
Using responseReader As New StreamReader(responseStream)
Dim json As String = responseReader.ReadToEnd()
shortUrl = Regex.Match(json, """id"": ?""(?<id>.+)""").Groups("id").Value
End Using
End Using
End Using
Catch ex As Exception
' if Google's URL Shortner is down...
System.Diagnostics.Debug.WriteLine(ex.Message)
System.Diagnostics.Debug.WriteLine(ex.StackTrace)
End Try
Return shortUrl
End Function
Shorten(yourlink.com)
Hope this helps some