D
D
danilasar2021-03-20 19:38:03
PHP
danilasar, 2021-03-20 19:38:03

How to access stored procedures through the VK API?

Good day. I wrote an application for sorting subscribers. For the same purpose, I created a small stored procedure on the side of VKontakte:

// VKScript
return API.users.search({
    "sex":Args.sex,
    "age_from":Args.minAge,
    "age_to":Args.maxAge,
    "group_id":Args.groupId,
    "count":Args.count,
    "offset": Args.offset
})[email protected];

And I refer to it in the standard way:
var_dump(json_decode(file_get_contents("https://api.vk.com/method/execute.SearchUsersBy?sex={$sex}&minAge={$minAge}&maxAge={$maxAge}&count={$count}&groupId={$groupId}&v=5.130&access_token=МОЙ_СЕРВИСНЫЙ_КЛЮЧ_ДОСТУПА")));

Link
https://api.vk.com/method/execute.SearchUsersBy?sex=2&minAge=15&maxAge=16&count=&groupId=&v=5.130&access_token=МОЙ_СЕРВИСНЫЙ_КЛЮЧ_ДОСТУПА
error JSON returned:
{"error":{"error_code":28,"error_msg":"Application authorization failed: method is unavailable with service token.","request_params":[{"key":"sex","value":"2"},{"key":"minAge","value":"15"},{"key":"maxAge","value":"16"},{"key":"count","value":""},{"key":"groupId","value":""},{"key":"v","value":"5.130"},{"key":"method","value":"execute.SearchUsersBy"},{"key":"oauth","value":"1"}]}}

That is, I am incorrectly authorized. I went to the documentation about excute methods and it turned out that they cannot be accessed with a service access key. But it is also impossible to knock with the access key of the same community: the method I created is available only for my application, therefore, you need to use the service key. However, I tried. As expected, without success.
If there are VK API experts here, could you please tell me what the error is?

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