V
V
vadim21vek2018-11-08 10:07:00
In contact with
vadim21vek, 2018-11-08 10:07:00

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

3 answer(s)
B
bublik1337, 2018-11-23
@bublik1337

<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;
}
?>

A
Alams Stoyne, 2018-11-08
@alams_stoyne

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).

D
Dmitry_Fifth, 2018-11-08
@Dmitry_Fifth

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 question

Ask a Question

731 491 924 answers to any question