There is a site with already working authorization.
For the site in VK created an application with a website type.
There is a need to add the opportunity to the site on behalf of the application Send Message to users via VK API
Is it possible like this? As far as I understood, not all methods are available for applications like “Site”.
If possible, what method will correctly use?
Answer 1, Authority 100%
Today there are the following options for sending a message to the user VK:
- from another user VK
Messages.send ()
; - from the community in response to user request – Messages for Business ;
- Notifications from the application
Secure.sendNotification ()
; - Paid sending SMS
Secure.SendSMSnotification ()
.
Options 1-3 are not available to the “Site” application. But you can do this:
Get a user account in VKontakte, representing your site – & nbsp; fictional character, director, “face” site.
Create an application of the Standalone type, and get an idle token with Messages rights for it. Here you have to just once execute the procedure with copying tokens from the browser address line.
But now you have a token with whom you can write personal messages from site scripts. They will come on behalf of the account.
Most likely, users will write something in response – & nbsp; Process their answers.
Adjust some mechanism in case the token suddenly ceases to work – & nbsp; so that you immediately recognize and released a new one.
Answer 2, Authority 33%
You need to get access_token
manually, otherwise it will not have the right right. To do this, follow the link:
http://oauth.vk.com/oauth/authorize?redirect_uri=http://oauth.vk.com/blank.html& ;/blank.html& ;respondse_type=token& ;client_id= {app_id} & amp; scope = friends, Messages, Offline
In the address bar copy access_token
and use it to send messages:
https://api.vkontakte.ru/method/messages.send?user_id= {Receiver_VK_ID} & amp; message = {vk_msg} & amp; title = {vk_msg_title} & amp; access_token = {received_access_token}
p.s. The Offline parameter gives token an unlimited existence time.