Answer the question
In order to leave comments, you need to log in
Comments from the VK discussion to the site, how to do it?
You need to make a page with reviews on the site, and the reviews themselves should be loaded from the discussion of the VKontakte group. How to organize?
Answer the question
In order to leave comments, you need to log in
<meta charset="utf-8">
<?php
$token = ""; // access_token
$group_id = 51204300; // ID Группы без минуса
$topic_id = 33003964; // ID Топика
$get_count = curl('https://api.vk.com/method/board.getComments?group_id='.$group_id.'&topic_id='.$topic_id.'&v=5.60&access_token='.$token);
$jsonGetCount = json_decode($get_count,true);
$count = $jsonGetCount['response']['count'];
for ($i = 1; $i <= $count; $i++) {
$get = curl('https://api.vk.com/method/board.getComments?group_id='.$group_id.'&topic_id='.$topic_id.'&offset='.$i.'&count=1&v=5.60&access_token='.$token);
$jsonGet = json_decode($get,true);
$user_id = $jsonGet['response']['items'][0]['from_id']; // ID Автора
$date = $jsonGet['response']['items'][0]['date']; // Дата в unixtime
$text = $jsonGet['response']['items'][0]['text']; // Текст
$fname = $jsonGet['response']['profiles'][0]['first_name']; // Имя Автора
$lname = $jsonGet['response']['profiles'][0]['last_name']; // Фамилия Автора
/*
ОСТАЛОСЬ ТОЛЬКО ВЫВЕСТИ ЭТО ВСЕ. ДУМАЮ САМ СПРАВИШЬСЯ
*/
}
function curl($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
?>
This is if it’s just to save on the site: Widget for comments
If I understand you correctly, then you need to “Return a list of messages in a specific VK topic” there is no ready-made widget for this, but there is an API using which you can easily solve your problem (cases for a couple of hours).
I found the following solution using the API, but it was implemented back when token authorization was not required:
https://github.com/MainCorp/discussions-vk
As a result, VK now says nothing User authorization failed: no access_token passed . I got the token, but I don't quite understand how to put it in the d_reviews.php solution php file. If we can work it out collectively, that would be great. It is also important for me to resolve this issue.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question