X
X
xakmika12021-05-03 19:01:07
API
xakmika1, 2021-05-03 19:01:07

How to get by api avu group VK?

Guys, my code pulls out the link to the ava is not correct, how to fix the error?

public function FilterVkGroup($a) {
        if (!empty($a)) {
            if (preg_match("/^(http|https):\/\/(www.vk|vk).com\/([\.\-_a-zA-Z0-9]+)/i", $a)) {
                $url = parse_url($a);
                $path = $url['path'];
                preg_match_all('#(club|public)([0-9]+)#', $path, $name, PREG_SET_ORDER);
                if (!empty($name)) {
                    $groupid = $name[0][2];
                    $return_url = 'https://www.vk.com/'.$name[0][0];
                } else {
                    $groupid = substr($path,1);
                    $return_url = 'https://www.vk.com/'.$groupid;
                }
                $res = $this->url_get_contents('https://api.vk.com/method/groups.getById?&group_id='.$groupid.'&v=5.80&access_token='.$this->TokenVK);
                $resp = json_decode($res, true);
                if (isset($resp['response'])) {
                    if ($resp['response'][0]['is_closed'] == '0') {
                        return array('success', $return_url, $resp['response'][1]['photo_100'], 'Сообщество');
                    } else return array('error', 'Сообщество должно быть открытым для подписок!');
                } else return array('error', 'Сообщество не найдено, проверьте ссылку!');
            } else return array('error', 'Неверный формат ссылки!');
        } else return array('error', 'Вы не указали ссылку на задание!');
    }


It needs to be in this format
https://sun7-9.userapi.com//s//v1//ig2//1UP8qeZDTheOuq27ssDqHCI1-2D0YRd1O4TLj5oUOM_6WF_lKxarCvmb9iq3XYo3fLvJiB9CwvI0F9Dj74KQaw-z.jpg?size=100x0&quality=96&crop=0,0,639,639&ava=1


And he pulls like this
https://sun1-96.userapi.com/s/v1/ig2/SiFtS4aszJ4dzV_8HmmzsPJv1aSBXX5MJrliOcvpHotdgkmDYo8VB7QbUDVA0YImxybC85BOQ29GpxfBh4l_G67Q.jpg?size=200x0&quality=9

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question