R
R
rusgayfer2017-07-14 20:42:52
PHP
rusgayfer, 2017-07-14 20:42:52

How to send using the messages.send method?

I make notifications through VK. On behalf of the community to the user. By this code

// Уведомления через ВК
            $request = $main->requestVkAPI('messages.send', "user_ids={$ownerId}&title={$groupname}&message={$message}&attachment={$attachments}&access_token={$tokengroup}");

The title should contain a message like this:
$groupname = urlencode('Новое сообщение в группе:');

And you need to specify the name of this group after "New message in the group".
I take the name of the group again from the API
$groupInfo = $main->requestVkAPI('groups.getById', "group_ids={$groupId}&fields=name,screen_name,description,photo_100&access_token={$tokenadmin}");

$template->templateSetVar('group_name', htmlspecialchars($groupInfo[0]['name']));

That is, this code I can not get stuck here. An error occurs. Help!! I did it like this, it doesn't look right:$groupInfo[0]['name']
$groupname = urlencode($groupInfo[0]['name']);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
profesor08, 2017-07-14
@profesor08

var_dump($groupInfo);
And look what you have there

M
Mir, 2017-08-29
@mir546

in api vk it’s impossible to write to the user until he himself writes the first one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question