Answer the question
In order to leave comments, you need to log in
How to add a youtube video to a VKontakte group via the VK API?
There are wall.post and video.save methods.
The first one inserts the video as a link, not as a video clip.
The second uploads the video to the server, instead of inserting a video clip.
If you add a link from youtube through the browser manually, then everything is fine, but how to do it through the API?
Answer the question
In order to leave comments, you need to log in
//to vk
$link = 'https://youtu.be/'.$_POST['fild']; // ccылка на ютуб
$name = urlencode($item['title']); //название видео (не обязательно)
$description = 'https://post-hardcore.ru/video/'.$vid.'-'.$alt.'.html'; //описание видео
$wallpost = '0'; //опубливоать на стене (0 - нет, 1 - да)
$a = 'https://api.vk.com/method/video.save?group_id=23138673&link='.$link.'&name='.$name.'&description=' . urlencode($description) . '&wallpost=' . $wallpost . '&access_token=XYZ'; //собираем ccылку для запроса (XYZ - токен, rights to call this method: video)
$addvideo = file_get_contents(rtrim($a)); //отправляем запрос
$obj = json_decode($addvideo); //обрабатываем джисон
$upload_url = $obj->{'response'}->{'upload_url'}; //тут получаем ссылку для подтверждения добавления
file_get_contents(rtrim($upload_url)); //открываем ссылку
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question