За последние 24 часа нас посетили 20968 программистов и 1109 роботов. Сейчас ищут 369 программистов ...

Api Vk Проверка вступил ли в группу человек

Тема в разделе "PHP для новичков", создана пользователем t1ma, 30 май 2017.

Метки:
  1. t1ma

    t1ma Новичок

    С нами с:
    30 май 2017
    Сообщения:
    2
    Симпатии:
    1
    Начало: я сам разобрался как проверить вступил ли в группу человек(код ниже).
    Вопрос: как перед проверкой вывести окно с группой вк?
    Всем заранее спасибо.:)
    PHP:
    1.     <?php
    2.  
    3.     $client_id = ''; // ID приложения
    4.     $client_secret = ''; // Защищённый ключ
    5.     $redirect_uri = ''.$_SERVER["PHP_SELF"]; // Адрес сайта
    6.  
    7.       $url = 'http://oauth.vk.com/authorize';
    8.  
    9.     $params = array(
    10.         'client_id'     => $client_id,
    11.         'redirect_uri'  => $redirect_uri,
    12.         'response_type' => 'code'
    13.     );
    14.  
    15.     echo $link = '<button class="button special fit" style="box-shadow: rgb(255, 255, 255) 0px 0px 20px 10px;" onclick="window.location.href=\'' . $url . '?' . urldecode(http_build_query($params)) . '\'">2. Поставить лайк</button>';
    16.  
    17. if (isset($_GET['code'])) {
    18.     $result = false;
    19.     $params = array(
    20.         'client_id' => $client_id,
    21.         'client_secret' => $client_secret,
    22.         'code' => $_GET['code'],
    23.         'redirect_uri' => $redirect_uri
    24.     );
    25.  
    26.     $token = json_decode(file_get_contents('https://oauth.vk.com/access_token' . '?' . urldecode(http_build_query($params))), true);
    27.  
    28.     if (isset($token['access_token'])) {
    29.         $params = array(
    30.             'uids'         => $token['user_id'],
    31.             'fields'       => 'uid,first_name,last_name,screen_name,sex,bdate,photo_big',
    32.             'access_token' => $token['access_token']
    33.         );
    34.  
    35.         $userInfo = json_decode(file_get_contents('https://api.vk.com/method/users.get' . '?' . urldecode(http_build_query($params))), true);
    36.         if (isset($userInfo['response'][0]['uid'])) {
    37.             $userInfo = $userInfo['response'][0];
    38.             $result = true;
    39.         }
    40.     }
    41.  
    42.     if ($result) {
    43.    
    44.             $req = file_get_contents("https://api.vk.com/method/likes.getList?type=".type($row["link"])."&owner_id=".first($row["link"])."&item_id=".second($row["link"]));
    45.             $req = file_get_contents('https://api.vk.com/method/groups.isMember?group_id='.$idgroup.'&user_id='.$userInfo['uid'].'&extended=1');
    46.               $data = json_decode($req, true);
    47.               if($data['response']['member']==1){
    48.                 echo 'sostoit';
    49.                 $_SESSION['next'] = $_SESSION['next'] + 1;
    50.                 echo $_SESSION['next'];
    51.                 exit ('<html><head><meta http-equiv="Refresh" content="0; URL='.$seturl.'"></head></html>');
    52.               }else{
    53.                   echo 'nein';
    54.                 $_SESSION['next'] = $_SESSION['next'] + 0;
    55.                  exit ('<html><head><meta http-equiv="Refresh" content="0; URL='.$seturl.'"></head></html>');
    56.               }
    57.    
    58.     }
    59. }