Answer the question
In order to leave comments, you need to log in
What can be the offset parameter for the code that extracts the user's comments from the VK?
Hello. There is an interesting procedure for execute (I reproduce the code for this topic below ), which allows you to extract the comments of a specific user from the communities - or all at once if the user_id parameter was not passed. It was never possible to find an acceptable digital step for sequential enumeration of pages without gaps, so that the next command would continue from the comment where the previous one stopped. Is it possible to somehow define the values that the offset parameter can take ?
var owner_id = Args.owner_id;
var user_id = Args.user_id;
var offset = Args.offset;
var post_count = Args.post_count;
if (post_count == null)
post_count = 10;
// Получаем список постов
var posts = API.wall.get({
"owner_id": owner_id,
"offset": offset,
"count" : 100,
});
var i = 0;
var userComments = {};
while(i < posts.items.length && i < post_count)
{
var post_id = posts.items[i].id;
var comments = API.wall.getComments({
"owner_id": owner_id,
"post_id": post_id,
"count" : 100,
});
var j = 0;
while(j < comments.items.length)
{
if (user_id == null || comments.items[j].from_id == user_id)
userComments.push(comments.items[j]);
j = j + 1;
}
i = i + 1;
}
return userComments;
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