Answer the question
In order to leave comments, you need to log in
Posting VK API method wall.post, why no rights?
Good afternoon!
The task is to post articles from the site to the VK group.
I am guided by these pages:
https://vk.com/dev/authcode_flow_user
https://vk.com/dev/wall.post
1) I am creating a Standalone application.
2) I follow the authorization link:
https://oauth.vk.com/authorize?client_id=123456789&display=page&redirect_uri=https://сайт.ru/vk/callback.php&scope=offline,groups,wall&response_type=code&v=5.126
https://oauth.vk.com/access_token?client_id=123456789&client_secret=секретный_код_приложения&redirect_uri=https://сайт.ru/vk/callback.php&code=ранее_полученный_код
$text = 'Тест-пост в ВК с сайта';
$a = [
'owner_id' => '-1234567', // id группы
'user_id' => '123456789', // id приложения
'access_token' => '123456789123456789123456789123456789123456789123456789',
'v' => '5.126',
'message' => urlencode($text),
];
$json = file_get_contents('https://api.vk.com/method/wall.post?'.http_build_query($a));
$a = json_decode($json, true);
echo '<pre>'; print_r($a); echo '</pre>';
Answer the question
In order to leave comments, you need to log in
You may be getting the token incorrectly.
Try to get it from https://vkhost.github.io/
Go to [Settings].
Token type - [Community]
Application ID - [ID]
Community ID - [ID]
Rights - select the rights you need.
After you click on the receive button, you will be redirected to https://oauth.vk.com/ ........
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question