Answer the question
In order to leave comments, you need to log in
Who can help solve the problem with the widget?
Hello, in general, I create a widget for a game bot, but I get the following error:
{"error":{"error_code":100,"error_msg":"One of the parameters specified was missing or invalid: body is empty","request_params":[{"key":"method","value": "appWidgets.update"},{"key":"oauth","value":"1"},{"key":"v","value":"5.95"},{"key":"type ","value":"table"},{"key":"code","value":"return {\"title\":\"Топ лучших игроков\",\" head\":[{\"text\":\"Ник\"},{\"text\":\"ДеPSьги\",\"align\":\"right\"},{\" text\":\"опыт\",\"align\":\"right\"}],\"body\":[]};"}]}}
async function updateWidget() {
var tops = []
for (i=1;i<200000;i++) {
if(users[i]) {
if(users[i].right < 1) {
tops.push({id: users[i].uid, idvk: users[i].id, lvl: users[i].exp});
}
}
}
tops.sort(function(a, b) {
if (b.lvl > a.lvl) return 1
if (b.lvl < a.lvl) return -1
return 0
})
var script = {
title: `Топ лучших игроков`,
head: [
{
text: 'Ник'
},
{
text: 'Деньги',
align: 'right'
},
{
text: 'опыт',
align: 'right'
}
],
body: []
}
for (var g = 0; g < 10; g++) {
if (tops.length > g) {
var ups = g;
ups += 1;
if(g <= 8) ups = `${ups}`
if(g == 9) ups = `10`
script.body.push([
{
icon_id: `id${tops[g].idvk}`,
text: `${users[tops[g].id].tag}`,
url: `vk.com/id${tops[g].idvk}`
},
{
text: `${spaces(users[tops[g].id].balance)}$`
},
{
text: `${spaces(tops[g].lvl)}`
},
])
}
}
requests.post({url: 'https://api.vk.com/method/appWidgets.update', form:{
v: '5.95',
type: 'table',
code: `return ${JSON.stringify(script)};`,
access_token: 'Тут токен я водил'
}
},
function(err, resp, body) {
console.log(body)
console.log(tops)
})
}
updateWidget()
setInterval(updateWidget, 60000)
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