Advertisement
Guest User

Untitled

a guest
Apr 5th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.96 KB | None | 0 0
  1.     Dim ClientId As String = "18931b2a8a62667"
  2.     Public Function UploadImage(ByVal image As String)
  3.         Dim w As New WebClient()
  4.         w.Headers.Add("Authorization", "Client-ID " & ClientId)
  5.         Dim Keys As New System.Collections.Specialized.NameValueCollection
  6.         Try
  7.             Keys.Add("image", Convert.ToBase64String(File.ReadAllBytes(image)))
  8.             Dim responseArray As Byte() = w.UploadValues("https://api.imgur.com/3/image", Keys)
  9.             Dim result = Encoding.ASCII.GetString(responseArray)
  10.             Dim reg As New System.Text.RegularExpressions.Regex("link"":""(.*?)""")
  11.             Dim match As RegularExpressions.Match = reg.Match(result)
  12.             Dim url As String = match.ToString.Replace("link"":""", "").Replace("""", "").Replace("\/", "/")
  13.             Return url
  14.         Catch s As Exception
  15.             MessageBox.Show("Something went wrong. " & s.Message)
  16.             Return "Failed!"
  17.         End Try
  18.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement