【发布时间】:2015-10-30 12:26:13
【问题描述】:
我正在使用我自己的 instagram api 开发一些新程序。 除了遵循用户脚本外,一切对我来说都很好 我想关注我的用户 ID 列表 所以我使用这个代码
foreach (var item in listBox1.Items)
{
WebRequest request = WebRequest.Create("https://api.instagram.com/v1/users/"+item+"/relationship?access_token=" + Common.token2);
request.Proxy = null;
request.Method = "POST";
string postData = "action=follow";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
// Display the status.
MessageBox.Show(((HttpWebResponse)response).StatusDescription);
dataStream.Close();
response.Close();
new System.Threading.Thread(GetInfo).Start();
Thread.Sleep(TimeSpan.FromSeconds(2));
}
listBox1.Items.Clear();
它成功跟随前 5 个,然后返回
远程服务器返回错误:(429) UNKNOWN STATUS CODE。
【问题讨论】:
-
en.wikipedia.org/wiki/List_of_HTTP_status_codes 429 是“请求过多”。这可能会帮助您解决问题。
-
你知道请求太多了如何解决?
-
现在当我将它设置为休眠 5 秒时,它只跟随前 17 秒
标签: c# instagram instagram-api http-status-code-429