M
M
Maxim Grechushnikov2017-11-07 01:33:50
In contact with
Maxim Grechushnikov, 2017-11-07 01:33:50

Is it possible to somehow send messages to the wall in the VK group through cron?

Hello. Something I can’t figure out how to post messages on VKontakte from the server side.
Tools:
"atehnix/laravel-vk-requester": "^0.7.0",

'scope' => [
        'offline,wall,groups',
    ],


$api = new \ATehnix\VkClient\Client;
    $api->setDefaultToken("adb1eb859de7d1aa79ca1611b5876643798a4bf4c4956c8899d37572c9c9e2061bcb0852c50731262d48b");
    $response = $api->request('groups.get', ['user_id' => 285585401, 'extended'=>true, 'filter'=>'admin,editor,moder']);
    $groupId = $response['response']['items'][0]['id'];

    $response = $api->request('wall.post', ['owner_id' => 285585401, 'message'=> 'its work!']); // в данном случае пытаюсь разместить у себя на странице

Information on the Internet varies and I'm already a little confused. Some say you can't, some say you can. At the same time, a bunch of auto-posting services somehow work. Tell me where am I doing wrong?
ps user IDs and keys changed randomly

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vr5, 2017-12-21
@vr5

It is certainly possible to do this.
In your code, you mixed up two concepts from the VK API a little. User access key and service access key.
Your application receives a service access key when registering with vk developers. But the user's access key can be obtained by passing Oauth authorization. In the wall.post method, it is necessary to use the user's access key. Those. the algorithm is something like this: a user (or you yourself) clicks on your site on the link "Login via Vkontakte", in response he receives a key that you then use to make requests to vk.api

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question