D
D
dim4ik2015-03-26 10:09:20
PHP
dim4ik, 2015-03-26 10:09:20

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

1 answer(s)
H
Hakhagmon, 2015-07-03
@Hakhagmon

//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)); //открываем ссылку

$wallpost = '0'; - by the way, I didn’t check this one, mb access to the wall will still be needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question