12 Years of Service
68%
[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]
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]