Answer the question
In order to leave comments, you need to log in
How to fix the script for sending a VK message via the API?
I am writing a script to send a VK message using the VK API and NodeJS
What I have:
var needle = require('needle');
var fs = require('fs');
var token=".....";
var msg = "MSG";
fs.readFile('url.txt', 'utf8', function(err, contents) {
var sId = [];
sId=contents.split("\n");
var i=0;
var t = setInterval(function(){
if(sId[i] !== undefined)
{
var url = "https://api.vk.com/api.php?oauth=1&method=messages.send&user_id="+sId[i]+"&message="+msg+"&v=5.67&access_token="+token;
needle.get(url, function(err, res){
if (err) throw err;
console.log(sId[i],res.body)
});
}
i++;
if(i > sId.length)
clearInterval(t);
},10000);
});
if (err) throw err;
^
Error: Parse Error
at TLSSocket.socketOnData (_http_client.js:444:20)
at TLSSocket.emit (events.js:125:13)
at addChunk (_stream_readable.js:269:12)
at readableAddChunk (_stream_readable.js:256:11)
at TLSSocket.Readable.push (_stream_readable.js:213:10)
at TLSWrap.onread (net.js:590:20)
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