0

Подскажите пожалуйста на примере как правильно использовать (вызывать) метод execute из API ВК (Node.js)

1 ответ 1

0

Для начала вам необходимо написать сам vk-script, затем данный скрипт передаёте в параметре code метода execute. Например получение репостов из 25 постов:

var data = []; // массив ваших данных
var script = " 
   var posts = [];
   var count = 0;

   while(count<"+data.lenght) {
      var info = API.wall.getReposts({'owner_id':"+data[count][0]+", 'post_id':"+data[count][1]+"});
      posts.push(info.profiles);
      count = count+1;
    }

return posts; 
";

var http = require('http');

var options = {
  host: 'https://api.vk.com/method',
  port: 80,
  path: '/execute?code='+script
};

http.get(options, function(response){
  response.on('data', function(chunk){
    //обработка ответа
  });
}).on("error", function(e){
  //обработка ошибки
});

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.