W
W
WiNNeR_tig2021-09-11 22:49:03
API
WiNNeR_tig, 2021-09-11 22:49:03

The video.get API VK method in the player field gives a link to youtube and not the player vk.com/video_ext.php?

The video.get API VK method in the player field gives a link to youtube and not the player vk.com/video_ext.php ?

function api($method, $params = array())
{
    $params['access_token'] = ACCESS_TOKEN;
    $params['v'] = "5.58";

    $url = 'https://api.vk.com/method/' . $method . '?' . http_build_query($params);
    $response = file_get_contents($url);
    return json_decode($response, true);
}

$api = api('video.get', array(
    'videos' => '429393901_456239017',
));

print_r($api);


answer
Array
(
    [response] => Array
        (
            [count] => 1
            [items] => Array
                (
                    [0] => Array
                        (
                            [can_comment] => 1
                            [can_edit] => 1
                            [can_like] => 1
                            [can_repost] => 1
                            [can_subscribe] => 0
                            [can_add_to_faves] => 1
                            [can_add] => 1
                            [can_attach_link] => 1
                            [comments] => 0
                            [date] => 1631385401
                            [description] => https://post-hardcore.ru/video/-.html
                            [duration] => 641
                            [photo_130] => https://sun9-56.userapi.com/TsuuZn5aKhErJY976JYg5aGb2XqhKy0cdLc7Cg/Q_XtqZhNFlg.jpg
                            [photo_320] => https://sun9-64.userapi.com/np-TU_ZudVY24NVFHuLc6cIg1qWCbMmBqwC_qg/qTnTmuohB1Y.jpg
                            [photo_800] => https://sun9-44.userapi.com/vr9IpizwK9f4QTio0Q5RTv8TqkIIIBhy-AsiHA/YSqA0lqwi9c.jpg
                            [id] => 456239017
                            [owner_id] => 489393901
                            [title] => Тест С
                            [player] => https://www.youtube.com/embed/IJKEhleHhDk?__ref=vk.api
                            [converting] => 0
                            [views] => 2
                            [local_views] => 2
                            [platform] => YouTube
                        )

                )

        )

)


And you need one
Array
(
    [response] => Array
        (
            [0] => 1
            [1] => Array
                (
                    [vid] => 159622161
                    [owner_id] => 23962687
                    [title] => Nero – Guilt (Official Video)
                    [description] => ↳ vk.com/dubstep_top
                    [duration] => 181
                    [link] => video159622161
                    [image] => http://cs12850.userapi.com/u27720818/video/m_367520e6.jpg
                    [image_medium] => http://cs12850.userapi.com/u27720818/video/l_a956702d.jpg
                    [date] => 1302727066
                    [views] => 10479
                    [files] => Array
                        (
                            [mp4_240] => http://cs12850.userapi.com/u27720818/videos/4c4e2b2044.240.mp4
                            [mp4_360] => http://cs12850.userapi.com/u27720818/videos/4c4e2b2044.360.mp4
                            [mp4_480] => http://cs12850.userapi.com/u27720818/videos/4c4e2b2044.480.mp4
                            [mp4_720] => http://cs12850.userapi.com/u27720818/videos/4c4e2b2044.720.mp4
                        )

                    [player] => http://vk.com/video_ext.php?oid=23962687&id=159622161&hash=008045cc2d45fd4d
                )

        )

)


Where is the link to the player with hash
[player] => https://vk.com/video_ext.php?oid=470485952&id=4562...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Puma Thailand, 2021-09-12
@opium

Well, because there is probably a video from YouTube

N
Nikola_SFB, 2021-09-18
@Nikola_SFB

In general, it is clear that the VK API itself returns the wrong link.
You can try to combine API + write a bot + deploy everything on a light VDS.
To get just the necessary cache at the end, but this is such a solution.
I would say temporary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question