D
D
Daniel2018-06-21 15:30:05
API
Daniel, 2018-06-21 15:30:05

How to send message via vk open api with client js?

Connected open api to the page

<script src="https://vk.com/js/api/openapi.js?154" type="text/javascript"></script>
    <script type="text/javascript">
        VK.init({
            apiId: 12345
        });
    </script>

Then I authorize the user
like this
VK.Auth.login(r => {
                if (r.session) {
                    resolve(r);
                } else {
                    reject(r);
                }
            }, 4096);//это маска для получения доступа к сообщениям

Then I try to send a message like this
VK.Api.call('messages.send', {user_id:123, message:"text", v: '5.80'}, function (r) {
                if (r.error)
                {
                    reject(r.error);
                }
                resolve(r);
            });

I get the error
"Access denied: no access to call this method"
Enabling / disabling open api in the settings does not affect the work
5b2b9a20bd238899667779.png
Help me figure it out

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