• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

.NET Imgur API [Vb.net]

Status
Not open for further replies.

fudmario

Leech
User
Joined
Feb 23, 2013
Messages
202
Reputation
0
Reaction score
1,098
Points
143
Credits
0
‎12 Years of Service‎
68%
[HIDE-THANKS][LENGUAJE=vb.net]Imports System.Net

Imports System.Text

Imports System.IO

dim ClientId as string = "Put your client id here"

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 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

[/LENGUAJE]

[LENGUAJE=vb.net]

'Ejemplo de Uso:

'dim url as string = UploadImage(textbox1.text) 'path to the image

'messagebox.show(url)

[/LENGUAJE]

Fuente: pc-tips.net[/HIDE-THANKS]

 
Last edited by a moderator:
Re: Imgur API [Vb.net]

thank you :$

 
Status
Not open for further replies.
Back
Top