B
B
bmalets2015-03-30 17:41:45
ruby
bmalets, 2015-03-30 17:41:45

How to send messages using vkontakte API?

I am writing a rails application, there is a need to send notifications to many users at once.
Is it possible, using the VK API, to send a message or notification from a VK group or VK application to several users at once?
If anyone has encountered this problem, implemented similar features, or used some pre-made lib or gem,
please push me in the right direction.
More interested in the algorithm and the sequence of requests and their parameters, but do not refuse the code either.
What problems arose when interacting with VK-API?
Does VK consider sending a notification to many users as spam?
Does it ban for a large number of requests?
Thanks in advance.
PS I found some interesting methods in the documentation, but I didn’t really understand how they can be used due to the fact that there are absolutely no sensible examples:
- https://vk.com/dev/messages.createChat
- https://vk.com/dev /messages.send
There is a "vkontakte_api" gem, but it does not allow sending messages.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Rubanyuk, 2015-04-01
@bmalets

To send messages, the application must be Standalone . VKontakte limits the number of requests to the API: no more than 3 requests per second from one application.
The code implies working with an already received access token (specifically point number 3)

params = "user_id=13371337&message=notification+text";
token = "access_token=xxxxxxxxxxxxxx";
method = "messages.send";
request = "https://api.vk.com/method/"+ method +"?"+ params +"&"+ token;

Actually, request is a ready-made request for sending a "notification text" message to user id13371337 . The request should return mid messages as JSON

M
Max, 2015-03-30
@AloneCoder

When I need some code or an example of it, I always go to github search

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question