A
A
Arthur2015-07-23 12:16:10
API
Arthur, 2015-07-23 12:16:10

Is it possible to search by a hash like #vakhtang on closed group discussions?

Hello.
Suggest a solution to the problem.
There is a CLOSED group in VK, in the discussions of which they write topics with one tag like #vakhtang.
I am the admin of this group and I want to upload messages from this group on my site that have these tags.
And so that you can view data on the site without authorization.
I tried to do it through Api vk, I made an application, but I almost broke my head - I didn’t decide.
Tell me, is there a ready-made solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Baha Rustamov, 2015-07-23
@by133312

1. Display a list of messages ( vk.com/dev/board.getComments )
2. Loop and if and ready.
if (preg_match("/#Vakhtang/", $comment[$i])) {
//Output
}
Maybe someone won't like it.
Here is an example:

<?php
  $club_id = '175'; // ID группы
  $topic_id = '26825039'; // ID обсуждения (Пример: http://vk.com/topic-175_26825039 -- вводить 26825039)
  $text = 'if'; // Текст который нужно найти
  
  $getComments = file_get_contents('https://api.vk.com/method/board.getComments?group_id='.$club_id.'&topic_id='.$topic_id);
  $json_comments = json_decode($getComments,1);
  
  for($i = 0; $i < $json_comments['response']['comments'][0]; $i++) {
    if (preg_match("/".$text."/", $json_comments['response']['comments'][$i]['text'])) {
      $result .= '<a href="http://vk.com/topic-'.$club_id.'_'.$topic_id.'?post='.$json_comments['response']['comments'][$i]['id'].'">Ваш текст «'.$text.'» совпал.</a><br>'; //Выводим ссылку
    }
  }
  // Если нашёл текст, то вывел, если текста нету, то вывел ERROR
  if($result) {
    Echo $result;
  } else {
    Echo "В данный момет, нечего не найдено.";
  }
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question