I found a solution for posting to the VKontakte community with a photo https://habrahabr.ru/post/226585/

require_once('../src/Vkontakte.php'); $accessToken = '1021c.....1cce4'; $vkAPI = new \BW\Vkontakte(['access_token' => $accessToken]); if ($vkAPI->postToPublic(23916815, "Привет Хабр!", '../../../images/gtiradio_logo.png', ['вконтакте api', 'автопостинг', 'первые шаги'])) { echo "Ура! Всё работает, пост добавлен\n"; } else { echo "Фейл, пост не добавлен(( ищите ошибку\n"; } 

gives out

 Parse error: syntax error, unexpected '[', expecting ')' in /home/..../public_html/php/postingvk/example/post_to_vk_group.php on line 6 

this is a string

  $vkAPI = new \BW\Vkontakte(['access_token' => $accessToken]); 

What's wrong?

    1 answer 1

    You most likely have a php version below version 5.4. Starting with it, you can use the short syntax for defining arrays [] , and before it, array() .

    • so I thought so too ... - Alexander Sizintsev