Home computickets Send message to the user via the VK API from the application...

Send message to the user via the VK API from the application with the type “Website”

Author

Date

Category

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:

  1. from another user VK Messages.send () ;
  2. from the community in response to user request – Messages for Business ;
  3. Notifications from the application Secure.sendNotification () ;
  4. 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.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions