I have this code, where when using the command /lastvideo
it shows the last video of my youtube channel, however when trying to use it it only shows the youtube link, not the video
Php code
//CANAL
$canal = '1fHyqwbfORgIedvQ5fmWZQ';
//--------------------------------------------------------//
switch($mensagem){
case "/lastvid":
sendMessage($chatid, ($yt->lastVideo($canal)));
break;
Call 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;
}
}