0
I have this code, where when using the command /lastvideo
it shows the latest video from my youtube channel, but when trying to use it only shows the youtube link, not the video
Code in Php
//CANAL
$canal = '1fHyqwbfORgIedvQ5fmWZQ';
//--------------------------------------------------------//
switch($mensagem){
case "/lastvid":
sendMessage($chatid, ($yt->lastVideo($canal)));
break;
Calls this function:
class YouTube {
public $cid;
public function lastVideo ($cid){
$ulast = 'https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=' .$cid. '&maxResults=1&order=date&type=video&key=xxxxxxxxxxxxxxx';
$glast = @file_get_contents($ulast);
$dlast = json_decode($glast, true);
$vid = @$dlast['items'][0]['id']['videoId'];
$vname = @$dlast['items'][0]['snippet']['title'];
//Condition
$ret = "Assista meu ultimo video: " .$vname. "\n http://youtu.be" .$vid;
return $ret;
}
}
You have to take the id from the last video, send it to the database, update the table, and then put it on Youtube. I recommend the following links : https://stackoverflow.com/questions/6617567/how-to-get-the-id-of-the-latest-uploaded-video-in-a-youtube-channel and https://stackoverflow.com/questions/412467/how-to-embed-youtube-videos-in-php
– Monteiro
Possible duplicate of How to always catch the last video from a Youtube channel?
– Francisco