PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи

Страниц (1): [1]

> Найдено сообщений: 1
Ushangi Отправлено: 04 Апреля, 2017 - 19:23:36 • Тема: Помогите исправить скрипт • Форум: Если скрипт не работает

Ответов: 1
Просмотров: 901
Уважаемые гуру. Помогите поправить скрипт.
Данный скрипт выводит записи из обсуждения группы ВК. Выводится и сообщение участника группы и ответ администратора. Надо чтобы выводились только сообщения участника группы. заранее большое спасибо.
PHP:
скопировать код в буфер обмена
  1.  
  2. <?
  3.   function vk_query($url, $params) {
  4.        $ch = curl_init();
  5.       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  6.       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  7.        curl_setopt($ch, CURLOPT_HEADER, false);
  8.       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  9.       curl_setopt($ch, CURLOPT_IPRESOLVE, CURLOPT_IPRESOLVE_V4);
  10.        curl_setopt($ch, CURLOPT_URL, $url);
  11.       curl_setopt($ch, CURLOPT_REFERER, $url);
  12.       curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  13.        curl_setopt($ch, CURLOPT_POST, true);
  14.       curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
  15.       $result = curl_exec($ch);
  16.       curl_close($ch);
  17.       return $result;
  18.   }
  19.   $cash_time = file_get_contents('cash_time.txt');
  20.   if (time() > $cash_time){
  21.     $result = json_decode(vk_query('https://api.vk.com/method/board.getComments', array(
  22.     'group_id' => '116937591',
  23.     'topic_id' => '33525571',
  24.     'count' => '100',
  25.     'extended' => '1',
  26.     'sort' => 'asc'
  27.     )), true);
  28.     $update = false;
  29.     $profil_arr = array();
  30.     foreach ($result['response']['profiles'] as $profil){
  31.       $profil_arr[$profil['uid']] = $profil;
  32.       $update = true;
  33.     }
  34.  
  35.     $html = '
  36.    <div align="left">
  37.    <div class="d_table vk_comment" style="margin-top: 50px; ">';
  38.     foreach ($result['response']['comments'] as $comment)
  39. {
  40.       if (!empty($comment['from_id']))
  41. {
  42.       $profil = $profil_arr[$comment['from_id']];
  43.       $text = $comment['text'];
  44.       preg_match('@\[(.*)\:(.*)\|(.*)\]@', $text, $m);
  45.       if (!empty($m[0]))
  46. {
  47.              $uid = $m[1];
  48.              $name = $m[3];
  49.              $r = '<a class="vk_fio" href="https://vk.com/'.$uid.'" target="_blank">'.$name.'</a>';
  50.  
  51.       }
  52.  
  53.       $text = preg_replace('@\[.*\]@', $r, $text);
  54.       $html .= '
  55.      <div class="d_tr col-md-12">
  56.      <div class="d_td vk_img col-md-2"><img src="'.$profil['photo_medium_rec'].'" width="150" height="150" border="0"></div>
  57.  
  58.      <div class="d_td col-md-10">';
  59.       if ($comment['from_id'] != 101){
  60.         $html .= '<div class="vk_fio_title">Отзыв оставил:<span> '.$profil['first_name'].' '.$profil['last_name'].' </span>'.date('d.m.Y H:i', $comment['date']).'</div>';
  61.       } else {
  62.         $html .= '<div class="vk_fio">'.$profil['first_name'].' '.$profil['last_name'].'</div>';
  63.       }
  64.       $html .= '<div class="vk_text"><blockquote>'.$text.'</blockquote></div>
  65.        
  66.        </div>
  67.      </div>';
  68.       }
  69.     }
  70.     $html .= '
  71.    </div>
  72. <hr/>
  73.    </div>';
  74.     if ($update == true){
  75.       $cash_live = time() + 1;
  76.       file_put_contents('cash_time.txt', $cash_live);
  77.       file_put_contents('cash_vk.html', $html);
  78.       echo $html;
  79.     } else {
  80.       $cash_html = file_get_contents('cash_vk.html');
  81.       echo $cash_html;
  82.     }
  83.   } else {
  84.     $cash_html = file_get_contents('cash_vk.html');
  85.     echo $cash_html;
  86.   }
  87. ?>
  88.  
  89.  

Страниц (1): [1]
Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB