B
B
Billy Milligan2013-12-28 16:10:38
PHP
Billy Milligan, 2013-12-28 16:10:38

VK API how to make a post in a group?

Application type site, getting a token:

https://oauth.vk.com/authorize?client_id=<app_id>&scope=photos,wall,offline&redirect_uri=https://oauth.vk.com/blank.html&response_type=token

I copy the token, paste it, send everything in this way (owner_id naturally with "-"):
https://api.vk.com/method/wall.post?owner_id=<id группы>&message=<текст сообщения>&access_token=<ранее полученный токен>

I get error 20 "Permission to perform this action is denied for non-standalone applications" from the server.
It turns out that the application must be standalone?
If I create a new application already standalone, will the problem be solved?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
codercat, 2013-12-28
@codercat

From the VKontakte documentation:
This method is available only to Standalone applications and web applications that use the confirmation window.

R
Ruslan, 2014-03-22
@iRusel

Of course, off topic, but can anyone share an example for php posting to a VK group?

Y
ystneris, 2018-10-03
@ystneris

I wrote a banal function. So far without attachment files. Just send text.

function VK_POST($text) {
  define('TOKEN','<токен приложения>');
  define('GROUP_ID','<ID группы>');
  define('API_VERSION','5.62');

  $url = sprintf('https://api.vk.com/method/wall.post?');
  $ch = curl_init();
  curl_setopt_array( $ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_SSL_VERIFYPEER => FALSE,
    CURLOPT_SSL_VERIFYHOST => FALSE,
    CURLOPT_POSTFIELDS => array(
      'owner_id' => GROUP_ID,
      'from_group' => 1,
      'message' => $text,
      'access_token' => TOKEN,
      'v' => API_VERSION
    ),
    CURLOPT_URL => $url,
  ));
  $query = curl_exec($ch);
  curl_close($ch);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question