Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim ClientId As String = "18931b2a8a62667"
- Public Function UploadImage(ByVal image As String)
- Dim w As New WebClient()
- w.Headers.Add("Authorization", "Client-ID " & ClientId)
- Dim Keys As New System.Collections.Specialized.NameValueCollection
- Try
- Keys.Add("image", Convert.ToBase64String(File.ReadAllBytes(image)))
- Dim responseArray As Byte() = w.UploadValues("https://api.imgur.com/3/image", Keys)
- Dim result = Encoding.ASCII.GetString(responseArray)
- Dim reg As New System.Text.RegularExpressions.Regex("link"":""(.*?)""")
- Dim match As RegularExpressions.Match = reg.Match(result)
- Dim url As String = match.ToString.Replace("link"":""", "").Replace("""", "").Replace("\/", "/")
- Return url
- Catch s As Exception
- MessageBox.Show("Something went wrong. " & s.Message)
- Return "Failed!"
- End Try
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement