Answer the question
In order to leave comments, you need to log in
VK API: php script returns an error. What is the problem?
There is a php script for posting records to open VK communities using the wall.post method. When executed, we get an error:
“Error 100: One of the parameters specified was missing or invalid: invalid message param”
Following the manual for error codes:
“One of the required parameters was not passed or is incorrect.
Check the list of required parameters and their format on the method description page.»
I can’t fix the problem on my own, I can’t understand in which parameter the error occurs.
Request to those who know, help with a solution to the problem.
Script:
<?php
/*
VK-API WALL.POST We send an entry to the group using the post method, via CURL
*/
$group_id ='-46604125';
$token = file_get_contents('token.txt');
$api_ver = '5.74';
$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,
"from_group" => 0,
"Message" => $text,
"access_token" => $token,
"v" => '5.74',
),
CURLOPT_URL => $url,
));
$query = curl_exec($ch);
curl_close($ch);
$decoded = json_decode($query);
if(!$decoded) {
printf("VK returned unimaginable garbage: %s", $query);
}
else if( $decoded->error) {
printf("Error %d: %s\n", $decoded->error->error_code, $decoded->error->error_msg);
} else if( $decoded->response) {
printf("Post published with id %s\n", $decoded->response);
}
exit();
Answer the question
In order to leave comments, you need to log in
"message" should be lowercase.
Do you have now"Message" => $text,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question