如何从网址C#上传imgur上的图片 [英] How do I upload image on imgur from url C#
问题描述
我试图使用下面的代码在imgur.com上传图片
它可以工作几次但它返回429错误 - 请求太多
是否可以使用c#从imgur上传其他网址上的图像?
私有字符串upload_img_from_url(字符串old_img_url)
{
string new_img_url =;
string key =<< < my key =is =here =>>>;
尝试
{
使用(WebClient客户端=新WebClient())
{
client.Headers.Add(授权,客户端ID+ key);
string response = client.DownloadString(http://imgur.com/upload?url=+ old_img_url);
response = response.Substring(response.IndexOf(< li nk rel = \image_src \),response.IndexOf(
string str_href =href = \ (。*)\;
匹配匹配= Regex.Match(响应,str_href);
if(match.Success)
{
new_img_url = match.Groups [1] .Value;
}
}
}
catch(例外情况)
{
txt_ssulf_error.Text = ex.Message;
}
返回new_img_url;
}
我尝试了什么:
我试图使用旧的api版本上传
网址为http://图片网址> img>> iv>
查看错误消息:
429错误 - 请求太多很明显,您的发布速度比网站将允许你。
要么将你的邮政费率降低到他们会接受的水平,要么与网站技术支持人员交谈并询问他们该怎么做。
无论哪种方式,这都不是我们可以解决的问题!
Hi,
I have tried to upload images on imgur.com using this code below
It works for few times but it returns 429 error- too many requests
Is it possible to upload images from other url on imgur progrmmatically using c#?
private string upload_img_from_url(string old_img_url)
{
string new_img_url = "";
string key = "<<<my key="" is="" here="">>>";
try
{
using (WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Client-ID " + key);
string response = client.DownloadString("http://imgur.com/upload?url=" + old_img_url);
response = response.Substring(response.IndexOf("<link rel=\"image_src\""), response.IndexOf("
string str_href = "href=\"(.*)\"";
Match match = Regex.Match(response, str_href);
if (match.Success)
{
new_img_url = match.Groups[1].Value;
}
}
}
catch (Exception ex)
{
txt_ssulf_error.Text = ex.Message;
}
return new_img_url;
}
What I have tried:
I have tried to upload using old api version
the url was http://imgur.com/api/upload?url=<<the image url>>
But it returns 404 error
Look at the error message:
429 error - too many requestsIt's pretty clear that you are posting faster than the site will allow you to.
Either slow down your post rate to a level they will accept, or talk to the site technical support and ask them what to do about it.
Either way, this isn't a problem we can solve for you!
这篇关于如何从网址C#上传imgur上的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!