Jump to content
YOUR-AD-HERE
HOSTING
TOOLS
992Proxy

Locked Imgur API [C#]


fudmario

Recommended Posts

[HIDE-THANKS][LENGUAJE=C#]

using System.Net;

using System.Text;

using System.IO;

 

 

string ClientId = "Put your client id here";

public object UploadImage(string image)

{

WebClient w = new WebClient();

w.Headers.Add("Authorization", "Client-ID " + ClientId);

System.Collections.Specialized.NameValueCollection Keys = new System.Collections.Specialized.NameValueCollection();

try {

Keys.Add("image", Convert.ToBase64String(File.ReadAllBytes(image)));

byte[] responseArray = w.UploadValues("https://api.imgur.com/3/image", Keys);

dynamic result = Encoding.ASCII.GetString(responseArray);

System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("link\":\"(.*?)\"");

Match match = reg.Match(result);

string url = match.ToString.Replace("link\":\"", "").Replace("\"", "").Replace("\\/", "/");

return url;

} catch (Exception s) {

MessageBox.Show("Something went wrong. " + s.Message);

return "Failed!";

}

}

 

[/LENGUAJE]

 

[LENGUAJE=C#]//Ejemplo de Uso:

//string url = UploadImage(textbox1.text);

//path to the image

//messagebox.show(url);

[/LENGUAJE]

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.