S
S
saalaus2021-04-01 21:19:59
Python
saalaus, 2021-04-01 21:19:59

How to update VK widget via Python?

I got a community widget token via vkminiapps and getCommunityToken, and now I want to update the widget via a Python script, but to display user information, such as a name, here is an example code

var test = API.users.get()@.first_name;
    return {
    "title": "Заголовок виджета",
    "text": test[0],
    "descr": "Описание"
};

The widget should show the name of the user who visited the page
Next, a request is made to the appWidgets.update method, with a token and type = text, but an error occurs
One of the parameters specified was missing or invalid: text is empty

That is, the API simply returns an empty text, that is, it did not find anything, although if the same code is sent to the execute method, then information about the current user is displayed.
Question:
How do applications that update widgets work? Or what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
saalaus, 2021-04-02
@saalaus

in general, figured it out, it was necessary to take Args.uid - ID of the current user

var test = API.users.get({user_id: Args.uid})@.first_name;
    return {
    "title": "Заголовок виджета",
    "text": test[0],
    "descr": "Описание"
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question