Answer the question
In order to leave comments, you need to log in
Retrying users.search in a loop after an offset returns an incomplete response. What's wrong?
I get the number of users from the request. If there are more than 1000 of them (and there are 21215 of them), then in the loop I try to use the offset to bring everyone into dataGridView3
// получил количество пользователей
...
if (user_count > 1000)
{
do
{
USER_ID = GET_http(String.Format("https://api.vk.com/method/users.search.xml?" + request + "&offset=" + offset + "&count=1000&fields=photo_id&access_token={0}", Settings1.Default.token));
XmlDocument doc = new XmlDocument();
doc.LoadXml(USER_ID);
XmlNodeList items = doc.SelectNodes("response/user/uid");
foreach (XmlNode item in items)
{
k++;
if (item.LocalName == "uid")
dataGridView3.Rows.Add(item.FirstChild == null ? "" : k + ") " + item.FirstChild.Value, (item.NextSibling.InnerText == null ? "" : item.NextSibling.InnerText) + " " + (item.NextSibling.NextSibling.InnerText == null ? "" : item.NextSibling.NextSibling.InnerText), item.NextSibling.NextSibling.NextSibling == null ? "" : (item.NextSibling.NextSibling.NextSibling.InnerText == null ? "" : item.NextSibling.NextSibling.NextSibling.InnerText));
}
offset += 1000;
user_count -= 1000;
System.Threading.Thread.Sleep(50);
}
while (user_count > 0);
}
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<response list=\"true\">\n <count>21215</count>\n <user>\n <uid>ид человека</uid>\n <first_name> Имя </first_name>\n <last_name>Фамилия</last_name>\n <photo_id>ид фотки</photo_id>\n </user>\n ..... </response>\n"
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<response list=\"true\">\n <count>21215</count>\n</response>\n"
. After the offset, the number of group members is returned, but ID, first_name, last_name are returned. D What could be the problem? USER_ID = GET_http(String.Format("https://api.vk.com/method/users.search.xml?" + request + "&offset=0&count=1000&fields=photo_id&access_token={0}", Settings1.Default.token));
USER_ID = GET_http(String.Format("https://api.vk.com/method/users.search.xml?" + request + "&offset=1000&count=1000&fields=photo_id&access_token={0}", Settings1.Default.token));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question