Answer the question
In order to leave comments, you need to log in
How to set up an API in a contact to automatically add posts?
I'm trying to set up automatic publication of posts to a group.
When running on a local server - 'success!' but nothing is added to the group, what's wrong?
post_data.text "Тестовое сообщение"
token.txt: 'токен из 85 символов" // получен из группы
wall.post.php
<meta http-equiv="content-type" content="text/html; charset="utf-8">
<?php
$group_id = '-9894839';
$token = file_get_contents('token.txt');
$api_ver = "5.80";
$text = file_get_contents('post_data.txt');
$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,
"form_group" => 1,
"message" =>$text,
"access_token" =>$token,
"v" =>$api_ver,
),
CURLOPT_URL =>$url,
));
$query = curl_exec($ch);
curl_close($ch);
if(!$query){
printf('Error');
exit;
}
else{
printf('$success');
exit;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question