I
I
Iskander Gorsky2018-03-07 18:56:18
JavaScript
Iskander Gorsky, 2018-03-07 18:56:18

How to duplicate a piece of JS code with a condition?

Hey! The following code is a procedure for execute , with which you can return comments to a VKontakte post, by its number from the first post in the community (that is, without specifying the post ID). It also returns only the comments of an individual user, if his id is specified in user_id . And by extracting posts by serial numbers, firstly, it eliminates the need to specify in the arguments and get the exact post IDs in advance, and secondly, it allows you to track and accumulate comments from the walls of other communities on inoreader.com . That is, it will be enough to create an RSS feed on feed43.com with offset=1 in the arguments, then a second feed with offset=2(and so on - as needed), and then on inoreader.com combine these feeds into one continuous one and receive updates for about half an hour.
The problem is that the code returns only the first hundred comments, although the execute capabilities allow you to increase this number, in which I ask you to help. To do this, as it seems to the humanities, to a code fragment where a hundred comments are received, you need to add offset=0 , then remember the results and duplicate the fragment with the next hundred comments, but with the addition of offset=100 , and so on. What would be an example expression (because instead of the post ID " 8331059" - in the code it is enough to indicate its number on the community wall) of the following commands:

https://api.vk.com/method/wall.getComments?owner_id=-29534144&post_id=8331059&offset=0&count=100&v=5.35
https://api.vk.com/method/wall.getComments?owner_id=-29534144&post_id=8331059&offset=100&count=100&v=5.35
...

The code itself can be viewed with highlighting at the link: https://jsfiddle.net/qtzatamg/

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question